Skip to content

Incorrect File Sorting in Project Window #4180

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
Sgrikkardo opened this issue Mar 11, 2025 · 2 comments
Open

Incorrect File Sorting in Project Window #4180

Sgrikkardo opened this issue Mar 11, 2025 · 2 comments
Labels
feature It's a feature, not a bug. good first issue Good thing to start with, and don't be shy to ask for help!

Comments

@Sgrikkardo
Copy link

I've noticed an issue with the file sorting order in the Project Window. When files are named with numbers, such as "d3" and "d20", they are sorted purely alphabetically rather than numerically. As a result, "d20" appears before "d3".

  • OS: Windows 11
  • Tiled Version: 1.11.2
@Sgrikkardo Sgrikkardo added the bug Broken behavior. label Mar 11, 2025
@eishiya
Copy link
Contributor

eishiya commented Mar 11, 2025

Not a bug, rather a missing feature. Alphabetical sorting like this is sometimes desirable, as not all groups of digits in file names represent a single number each, or even a number at all. Windows has "smart" number sorting like you proposed by default and it's tripped me up more than a few times. I prefer the current sort myself, because it works well with both numeric and non-numeric digits, provided one uses leading 0s for the numeric ones.

However, it would be nice to have an option in that panel (or in Preferences, if this can apply elsewhere as well) to allow users to sort groups of digits as numbers (OP's proposal), or sort them as characters (current).

@bjorn
Copy link
Member

bjorn commented Mar 11, 2025

Currently I'm relying on QDir::SortFlags to do the sorting and unfortunately it does not support a numeric mode. Fortunately, Qt does provide this type of sorting through QCollator since 5.2, which we can use to implement this option after collecting the list of files (possibly relying on a sorting proxy model, to support toggling this optionafter folders have been scanned).

@bjorn bjorn added feature It's a feature, not a bug. good first issue Good thing to start with, and don't be shy to ask for help! and removed bug Broken behavior. labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug. good first issue Good thing to start with, and don't be shy to ask for help!
Projects
None yet
Development

No branches or pull requests

3 participants