montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.09k stars 185 forks source link

Sorted Collection by non-key/object property & Get by key #217

Open gmiklich opened 5 years ago

gmiklich commented 5 years ago

When looking through the collections, both the documentation and the source, I couldn't find one that would let me maintain a sorted collection of objects based off of a property of the object, but also retrieve an object by it's key. For instance, let's say we want to keep a list of People sorted by their age. I should be able to have the backing store keep a list of People in ascending age order, but also be able to retrieve a person by his/her name. The closest collection is probably the SortedMap, but again, both retrieval and sorting are stuck using the key. Am I missing something, or does that functionality not exist in this package?