From ed9988f9abd634da52342c97e0b7076bf648eb19 Mon Sep 17 00:00:00 2001 From: Kent Date: Tue, 25 Apr 2023 14:03:33 -0400 Subject: [PATCH] when sorting break ties with lexical comparison Signed-off-by: Kent --- collection.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/collection.go b/collection.go index a782358..d7a2d58 100644 --- a/collection.go +++ b/collection.go @@ -14,7 +14,11 @@ func (c Collection) Len() int { // Less is needed for the sort interface to compare two Version objects on the // slice. If checks if one is less than the other. func (c Collection) Less(i, j int) bool { - return c[i].LessThan(c[j]) + comp := c[i].Compare(c[j]) + if comp != 0 { + return comp < 0 + } + return c[i].Original() < c[j].Original() } // Swap is needed for the sort interface to replace the Version objects