Merge pull request #59 from rkfg/sort

Make gauge sort more stable
pull/63/head
Edouard 2 years ago committed by GitHub
commit 82acda22f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,6 +33,13 @@ func Int64Sort(a, b int64, o Order) bool {
return a > b
}
func Float64Sort(a, b float64, o Order) bool {
if o == Asc {
return a < b
}
return a > b
}
func UInt64Sort(a, b uint64, o Order) bool {
if o == Asc {
return a < b

@ -330,9 +330,9 @@ func NewChannels(cfg *config.View, chans *models.Channels) *Channels {
name: fmt.Sprintf("%-21s", columns[i]),
sort: func(order models.Order) models.ChannelsSort {
return func(c1, c2 *netmodels.Channel) bool {
return models.Int64Sort(
c1.LocalBalance*100/c1.Capacity,
c2.LocalBalance*100/c2.Capacity,
return models.Float64Sort(
float64(c1.LocalBalance)*100/float64(c1.Capacity),
float64(c2.LocalBalance)*100/float64(c2.Capacity),
order)
}
},

Loading…
Cancel
Save