File: sort.go

package info (click to toggle)
golang-github-blang-semver 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, experimental, sid
  • size: 176 kB
  • sloc: makefile: 3
file content (28 lines) | stat: -rw-r--r-- 555 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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))
}