Replaces stable sort with unstable sort (#30223)

This commit is contained in:
Brooks 2023-02-10 09:56:11 -05:00 committed by GitHub
parent 128ffbdf9b
commit d27c860249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -5007,8 +5007,10 @@ impl Bank {
#[cfg(not(test))]
assert!(!validator_stakes.is_empty());
// Sort first by stake and then by validator identity pubkey for determinism
validator_stakes.sort_by(|(pubkey1, staked1), (pubkey2, staked2)| {
// Sort first by stake and then by validator identity pubkey for determinism.
// If two items are still equal, their relative order does not matter since
// both refer to the same validator.
validator_stakes.sort_unstable_by(|(pubkey1, staked1), (pubkey2, staked2)| {
staked2.cmp(staked1).then(pubkey2.cmp(pubkey1))
});