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

Sort by key #8

Open
vigna opened this issue Nov 12, 2023 · 2 comments
Open

Sort by key #8

vigna opened this issue Nov 12, 2023 · 2 comments

Comments

@vigna
Copy link

vigna commented Nov 12, 2023

Feature suggestion: a version of the sort method with by_key, similar to sort_by_key for slices. This would avoid in many situations to have to define a struct containing a key and a value, when maybe tuples are sufficient.

@nessex
Copy link
Owner

nessex commented Nov 15, 2023

Thanks for the suggestion!

Actually, I played with having a sort_by_key a long time ago. The reason I didn't include it originally is because I couldn't get it to work without having it significantly slow things down. All these radix sort libraries are really fragile, a very small change in the inner hot loops can have orders of magnitude impact on the final performance. If I recall correctly, the issue here had something to do with the compiler's ability to inline the key function.

I'll take a look in the next few days, and see if anything has changed. There have been a bunch of compiler changes in the last few years and maybe something has improved there to allow this without the performance penalty.

@vigna
Copy link
Author

vigna commented Nov 15, 2023

I don't need it anymore as I have created a struct and implemented RadixKey, but if it doesn't come without a performance penalty I think it would be a great feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants