Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sortByRank misplaces undefined values for reversed comparison functions #2594

Closed
gibson042 opened this issue Oct 19, 2024 · 1 comment · Fixed by #2597
Closed

sortByRank misplaces undefined values for reversed comparison functions #2594

gibson042 opened this issue Oct 19, 2024 · 1 comment · Fixed by #2597
Labels
bug Something isn't working

Comments

@gibson042
Copy link
Contributor

(reflects Agoric/agoric-sdk#4260 )

sortByRank currently uses Array.prototype.sort directly, and so only works correctly when given a compare function that considers undefined strictly bigger (>) than everything else. This is because Array.prototype.sort bizarrely moves all undefineds to the end of the array regardless, without consulting the compare function. This is a genuine bug for us NOW because sometimes we sort in reverse order by passing a reversed rank comparison function.

See Agoric/agoric-sdk#4252 , which fixed the forward rank comparison so that sortByRank applied to it would be consistent. The remaining live problem is only where we use the reversed comparison.

@gibson042
Copy link
Contributor Author

Fixed by #2597

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant