Skip to content

Commit

Permalink
Use stable sort for sorting coins (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyricnz committed Oct 18, 2021
1 parent 73a0058 commit 30fa30c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cointop/favorites.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (ct *Cointop) GetFavoritesSlice() []*Coin {
}
}

sort.Slice(sliced, func(i, j int) bool {
sort.SliceStable(sliced, func(i, j int) bool {
return sliced[i].MarketCap > sliced[j].MarketCap
})

Expand Down
2 changes: 1 addition & 1 deletion cointop/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func (ct *Cointop) GetPortfolioSlice() []*Coin {
sliced = append(sliced, coin)
}

sort.Slice(sliced, func(i, j int) bool {
sort.SliceStable(sliced, func(i, j int) bool {
return sliced[i].Balance > sliced[j].Balance
})

Expand Down
2 changes: 1 addition & 1 deletion cointop/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (ct *Cointop) Sort(sortBy string, desc bool, list []*Coin, renderHeaders bo
if len(list) < 2 {
return
}
sort.Slice(list[:], func(i, j int) bool {
sort.SliceStable(list[:], func(i, j int) bool {
if ct.State.sortDesc {
i, j = j, i
}
Expand Down

0 comments on commit 30fa30c

Please sign in to comment.