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

Collection.sortBy doesn't use IndexedDB.cmp for Uint8Array values #2073

Closed
genki opened this issue Sep 21, 2024 · 0 comments · Fixed by #2074
Closed

Collection.sortBy doesn't use IndexedDB.cmp for Uint8Array values #2073

genki opened this issue Sep 21, 2024 · 0 comments · Fixed by #2074

Comments

@genki
Copy link
Contributor

genki commented Sep 21, 2024

Collection.sortBy function uses < or > for comparing values for the sort.

return aVal < bVal ? -order : aVal > bVal ? order : 0;

It causes unexpected behaviour for Typed arrays such as Uint8Array.
For example, it sorts the values in lexicographical order like this.

new Uint8Array([1,46]) > new Uint8Array([1,146])
> true

This is inconsistent to the treatment of the Typed arrays in the IndexedDB.
We have to use the IndexedDB.cmp for comparing function.

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

Successfully merging a pull request may close this issue.

1 participant