diff --git a/validator.go b/validator.go index 065c5a8..a44fb98 100644 --- a/validator.go +++ b/validator.go @@ -575,10 +575,15 @@ func ValidatorHandler(w http.ResponseWriter, r *http.Request, grpcConn *grpc.Cli validators := stakingRes.Validators - // sorting by delegator shares to display rankings + // sorting by delegator shares to display rankings (unbonded go last) sort.Slice(validators, func(i, j int) bool { firstShares, firstErr := strconv.ParseFloat(validators[i].DelegatorShares.String(), 64) secondShares, secondErr := strconv.ParseFloat(validators[j].DelegatorShares.String(), 64) + if !validators[i].IsBonded() && validators[j].IsBonded() { + return false + } else if validators[i].IsBonded() && !validators[j].IsBonded() { + return true + } if firstErr != nil || secondErr != nil { sublogger.Error(). diff --git a/validators.go b/validators.go index 365ea32..d881f9e 100644 --- a/validators.go +++ b/validators.go @@ -150,8 +150,13 @@ func ValidatorsHandler(w http.ResponseWriter, r *http.Request, grpcConn *grpc.Cl Msg("Finished querying validators") validators = validatorsResponse.Validators - // sorting by delegator shares to display rankings + // sorting by delegator shares to display rankings (unbonded go last) sort.Slice(validators, func(i, j int) bool { + if !validators[i].IsBonded() && validators[j].IsBonded() { + return false + } else if validators[i].IsBonded() && !validators[j].IsBonded() { + return true + } return validators[i].DelegatorShares.RoundInt64() > validators[j].DelegatorShares.RoundInt64() }) }()