medikoo / dbjs

In-Memory Database Engine for JavaScript
MIT License
28 stars 4 forks source link

Customisable iteration order of maps and sets #37

Open medikoo opened 9 years ago

medikoo commented 9 years ago

/cc @kamsi @nix1

Currenlty by default sets and maps are iterated by last modification order. For most cases it plays well, still it might be wise to expose compare method which can be overriden for certain use cases

e.g. we may have list of countries, that we want to be iterated alphabetically, we can define them that way in model, but what if want to assure alphabetical order in any language (where labels will be different for each language), with custom compare method, it'll be possible to assure universal alphabetical order for such type.