Make gauge sort more stable

pull/59/head
rkfg 2 years ago
parent d611b9d857
commit 1b278fff12

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