tpl/collections: Make sort stable

Fixes #9865
This commit is contained in:
Bjørn Erik Pedersen
2022-05-08 18:37:14 +02:00
parent 855e5869c6
commit 860c51c314
2 changed files with 32 additions and 2 deletions

View File

@@ -177,9 +177,9 @@ func (p pairList) Less(i, j int) bool {
// sorts a pairList and returns a slice of sorted values
func (p pairList) sort() any {
if p.SortAsc {
sort.Sort(p)
sort.Stable(p)
} else {
sort.Sort(sort.Reverse(p))
sort.Stable(sort.Reverse(p))
}
sorted := reflect.MakeSlice(p.SliceType, len(p.Pairs), len(p.Pairs))
for i, v := range p.Pairs {