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
Sorting files on filesize in app sorts alphabetically #7677
Comments
Seems to be working for me. Could you provide more information on how to reproduce this. |
@Nitwel IIRC
When sorting datasets that fit on the page, we sort on the client side for optimized performance. However, that sorts on the string value, which makes it alphabetical. This matches the reported
as that first load is done with a sort query in the API request, and therefore sorts on the database level. |
With that in mind, the question becomes: Is that something we can fix in the first place? We can't simply convert the value to a number first and then sort, as that can crash javascript altogether. One possible solution is to drop the client-side sorting altogether in favor of always using the API, but that's a bit of a shame as it makes sorting way slower for small data sets 🤔 |
Could we maybe use Javascript's |
Yeah, though I'm wondering how that interop works with JSON parse/stringify 🤔 Also, curiously enough, my Node runtime/Safari seem to handle massive int's just fine, so I'm wondering if BigInt is just an implementation detail under the hood we don't even have to think about? |
Maybe the solution is as simple as:
|
Good point! Seems like JSON doesn't support
Massive int's will work but they will loose precision (as any number in js is just a float). In your screenshots, the number litteral in code and the printed number aren't equivalent. You have to append an Also, |
Hello all, I believe this is fixed in #8570 More specifically on this chunk https://github.com/directus/directus/pull/8570/files#diff-9898b066ab280a7cd156ae0d26bea7373f99c17d512e2a20d9899fe8c57ed907R70-R91 Basically the solution was to do the sort on server side. If you think this is not solved yet, feel free to reach us in order to reopen. |
Preflight Checklist
Describe the Bug
In the admin app > file library, when sorting files on file size, files are sorted alphabetically.
This does not seem an issue when visiting the library from the menu, but it does when changing the sorting direction.
To Reproduce
What version of Directus are you using?
v9.0.0-rc.91
What version of Node.js are you using?
16.8.0
What database are you using?
Postgres 14
What browser are you using?
Chrome 92
What operating system are you using?
Windows 10
How are you deploying Directus?
Node app on server
The text was updated successfully, but these errors were encountered: