Use stable sort for sorting coins (#235)

pull/237/head
Simon Roberts 3 years ago committed by GitHub
parent 73a00588ba
commit 30fa30c057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
})

@ -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
})

@ -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
}

Loading…
Cancel
Save