...

Source file src/github.com/blang/semver/sort.go

Documentation: github.com/blang/semver

     1  package semver
     2  
     3  import (
     4  	"sort"
     5  )
     6  
     7  // Versions represents multiple versions.
     8  type Versions []Version
     9  
    10  // Len returns length of version collection
    11  func (s Versions) Len() int {
    12  	return len(s)
    13  }
    14  
    15  // Swap swaps two versions inside the collection by its indices
    16  func (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
    21  func (s Versions) Less(i, j int) bool {
    22  	return s[i].LT(s[j])
    23  }
    24  
    25  // Sort sorts a slice of versions
    26  func Sort(versions []Version) {
    27  	sort.Sort(Versions(versions))
    28  }
    29  

View as plain text