In PackageList, sort the package version from latest to oldest

This enables us to return the latest version of a package when no version is specified rather than the oldest.
Therefore, we don't need to modify the search algorithm to return the latest version of a package.
This commit is contained in:
Simon Aquino
2014-06-13 12:06:33 +01:00
parent ff77fbf5d9
commit e19a615641

View File

@@ -300,13 +300,13 @@ func (l *PackageList) Swap(i, j int) {
l.packagesIndex[i], l.packagesIndex[j] = l.packagesIndex[j], l.packagesIndex[i]
}
// Compare compares two packages by name in lexographical order and version
// Compare compares two packages by name (lexographical) and version (latest to oldest)
func (l *PackageList) Less(i, j int) bool {
iPkg := l.packagesIndex[i]
jPkg := l.packagesIndex[j]
if iPkg.Name == jPkg.Name {
return CompareVersions(iPkg.Version, jPkg.Version) == -1
return CompareVersions(iPkg.Version, jPkg.Version) == 1
}
return iPkg.Name < jPkg.Name