1package semver 2 3import ( 4 "sort" 5) 6 7// Versions represents multiple versions. 8type Versions []Version 9 10// Len returns length of version collection 11func (s Versions) Len() int { 12 return len(s) 13} 14 15// Swap swaps two versions inside the collection by its indices 16func (s Versions) Swap(i, j int) { 17 s[i], s[j] = s[j], s[i] 18} 19 20// Less checks if version at index i is less than version at index j 21func (s Versions) Less(i, j int) bool { 22 return s[i].LT(s[j]) 23} 24 25// Sort sorts a slice of versions 26func Sort(versions []Version) { 27 sort.Sort(Versions(versions)) 28} 29