Skip to content

"Alphabetical" sorting is not alphabetical - Sorted by ASCII code instead #15582

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
2 of 3 tasks
anobit opened this issue Apr 22, 2021 · 6 comments
Open
2 of 3 tasks
Labels

Comments

@anobit
Copy link

anobit commented Apr 22, 2021

Description

The alphabetical sorting is currently not alphabetical, as lower- and uppercase letters are "sorted" seperately. This is likely due to ASCII Code comparison (e.g. "B = 66", "a" = 97).
In the linked example i made three repositories to showcase this: Beta and Omega, starting both with uppercase letters and alpha, starting with a lowercase. With an alphabetical sorting it would be expected to be sorted as "alpha", "Beta", "Omega". Instead, "alpha" is pushed to the back.

Among other things, this can be an error source for people migrating old, inconsistently named VCS to Gitea.

Screenshots

image

@lafriks
Copy link
Member

lafriks commented Apr 22, 2021

What database are you using?

@anobit
Copy link
Author

anobit commented Apr 22, 2021

On the system i migrate to sqlite3. Which one the try.gitea.io instance uses, i do not know.

@lafriks
Copy link
Member

lafriks commented Apr 22, 2021

Yes, this is how sqlite does sorting, so it is only sqlite speciffic problem. To have case insensitive sorting sqlite needs COLLATE NOCASE ASC but I don't know if xorm supports that
cc @lunny

@lunny
Copy link
Member

lunny commented Apr 23, 2021

Just use OrderBy("name COLLATE NOCASE ASC") if it's sqlite

@KaKi87
Copy link

KaKi87 commented Feb 4, 2023

Hello,

I don't know about repo names, but the same issue is present for repo file names.
Personally I use MySQL.

Thanks

@wxiaoguang
Copy link
Contributor

I can see 2 problems here.

The first one is for "database collation". I think SQLite is too special for this case, and it doesn't seem worth to make XORM more complex to support the special sort order. It's highly recommended to use some rich-featured databases like MySQL/PgSQL, then you could convert the table/column collation to what you need.

The second one, I think it could be fixed by #29611

(I think this issue could be closed after #29611 gets merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants