Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 30fa30c

Browse files
authored
Use stable sort for sorting coins (#235)
1 parent 73a0058 commit 30fa30c

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

cointop/favorites.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (ct *Cointop) GetFavoritesSlice() []*Coin {
6464
}
6565
}
6666

67-
sort.Slice(sliced, func(i, j int) bool {
67+
sort.SliceStable(sliced, func(i, j int) bool {
6868
return sliced[i].MarketCap > sliced[j].MarketCap
6969
})
7070

cointop/portfolio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func (ct *Cointop) GetPortfolioSlice() []*Coin {
574574
sliced = append(sliced, coin)
575575
}
576576

577-
sort.Slice(sliced, func(i, j int) bool {
577+
sort.SliceStable(sliced, func(i, j int) bool {
578578
return sliced[i].Balance > sliced[j].Balance
579579
})
580580

cointop/sort.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (ct *Cointop) Sort(sortBy string, desc bool, list []*Coin, renderHeaders bo
2323
if len(list) < 2 {
2424
return
2525
}
26-
sort.Slice(list[:], func(i, j int) bool {
26+
sort.SliceStable(list[:], func(i, j int) bool {
2727
if ct.State.sortDesc {
2828
i, j = j, i
2929
}

0 commit comments

Comments
 (0)