aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/blang/semver/sort.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/blang/semver/sort.go')
-rw-r--r--vendor/github.com/blang/semver/sort.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/blang/semver/sort.go b/vendor/github.com/blang/semver/sort.go
new file mode 100644
index 0000000..e18f880
--- /dev/null
+++ b/vendor/github.com/blang/semver/sort.go
@@ -0,0 +1,28 @@
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}