go-omaha/vendor/github.com/blang/semver/sort.go
Stephen Demos e95ad781c1 vendor: vendor glide dependencies
this lets us specify dependencies more specifically and also build
binaries as a part of the project.
2017-12-05 14:46:15 -08:00

28 lines
555 B
Go

package semver
import (
"sort"
)
// Versions represents multiple versions.
type Versions []Version
// Len returns length of version collection
func (s Versions) Len() int {
return len(s)
}
// Swap swaps two versions inside the collection by its indices
func (s Versions) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Less checks if version at index i is less than version at index j
func (s Versions) Less(i, j int) bool {
return s[i].LT(s[j])
}
// Sort sorts a slice of versions
func Sort(versions []Version) {
sort.Sort(Versions(versions))
}