-
Notifications
You must be signed in to change notification settings - Fork 275
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
Add Sorted method #127
Add Sorted method #127
Conversation
This is a varient on `slices.Sorted` that makes it easy to get a sorted slice. This makes it easy to get the elements of the set into a sorted slice. Quite handy when using sets to build up unique elements but then needing a well defined iteration order.
A helpful wrapper around https://pkg.go.dev/[email protected]#Sort. I could add SortedFunc as well if wanted to wrap https://pkg.go.dev/[email protected]#SortFunc. |
@Frassle - thanks for your contribution. This seems like a nice and convenient helper func. I’ll look it over in detail along with your other posted issue likely tomorrow. Thanks for your interest and contribution! |
Noticed from your CI run that "slices" and "cmp" are only in go 1.21 so I've moved this to a new file that can be conditional by version. Won't break existing users, but anyone wanting to use sorted will need to be on 1.21. |
Hey @deckarep just to check in if you've had a chance to consider this yet? |
Thanks @Frassle for this change. Sorry I never got around to it but it looks good. Thanks @funwithbots for the pair of eyes. This will show up in release: v2.5.0 |
Thanks! And no worries about the time, I know how easy it is to lose track of things like this. |
This is a set variant on
slices.Sort
that makes it easy to get a sorted slice. This makes it easy to get the elements of the set into a sorted slice. Quite handy when using sets to build up unique elements but then needing a well defined iteration order.