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

SortedTable / SortedSet : tables and sets sorted by arbitrary order (lexicographical, ascending/descending ...) #11475

Open
mratsim opened this issue Jun 11, 2019 · 2 comments

Comments

@mratsim
Copy link
Collaborator

mratsim commented Jun 11, 2019

Summary

SortedTable and SortedSet:

A table/set implementation that is sorted according to a specific order (often lexicographic or ascending/descending for numbers).

Description

This was often requested in the forum, note that is this different from OrderedSet and OrderedTable that are sorted by insertion order.

Alternatives

The current workaround is to use OrderedTable and then the sort proc defined for OrderedTable. There is no sort for OrderedSets

Additional Information

For performance reason this probably requires a collection of tree datastructures first.

@akavel
Copy link

akavel commented Oct 11, 2019

I ended up defining a poor man's SortedSet for my own use based on seq & binarySearch when I needed this. I know I won't have many elements, so I did it in a simple yet inefficient way, but I'd love to be able to use a library container, stdlib or 3rd-party. Notably I had some bugs in the first implementation :/

@konsumlamm
Copy link
Contributor

Note that there is fusion/btreetables now, which provides sorted tables. They could be used to also implement sorted sets (see nim-lang/fusion#65).

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

No branches or pull requests

3 participants