Skip to content

More information about use cases #2

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

Open
littledan opened this issue Apr 7, 2025 · 1 comment
Open

More information about use cases #2

littledan opened this issue Apr 7, 2025 · 1 comment

Comments

@littledan
Copy link
Member

The comparison function here is not linguistically appropriate, so I'm trying to understand its use cases. In the README, you discuss how other programming languages and databases have code point order as the default for sorting. Can you share more about the use cases for the default search in those systems? I'm not sure why this is something we want to align with.

@mhofman
Copy link
Member

mhofman commented Apr 7, 2025

Not all data is meant to be presented to the user. When processing data we need a deterministic way of sorting it that is portable. Sorting strings by codepoint is the only portable order that makes sense (UTF-16 code units are only a feature of languages that were created before we had modern Unicode, like Java and JavaScript).

More specifically our system implements "Virtual Collections" that are transparently backed by a SQLite DB. These collections do not use insertion order for iteration but instead use a well defined sort based on data types. We also have compatible collection implementation that keep data in JS heap, where we need to sort keys the same as the DB would, and we need to implement a custom sort function that compares stings by codepoints to be compatible. We also need to access these virtual collections from other systems.

This is one example. In general sorting linguistically is for humans. Sorting for computer systems should rely on a portable sort order.

Please note I am not asking to change the default sort and comparison order of strings in JavaScript. Just that a compare function be provided by the standard library to facilitate opt-in sort and comparison using code point order.

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