File list sorting: numeric order vs lexicographical order #191838
Replies: 2 comments
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
I've seen this issue with numbered files. GitHub currently uses lexicographical sorting, which isn't ideal for numbers. For example, "file-10" appears before "file-2" because "1" comes before "2" in string comparison. Zero-padding (file-01, file-02) helps but becomes cumbersome with large numbers. I'd suggest adding a natural sort option or automatic detection of numeric suffixes. This would align with how humans expect ordered files to behave, especially in documentation or migration workflows. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Product Feedback
💬 Feature/Topic Area
Feed
Body
Body
When browsing files in a repository, filenames with numbers are sorted lexicographically instead of numerically.
For example:
Example of lexicographical sorting in a real repository (e.g., 0xAX/linux-insides on GitHub)
This makes it harder to navigate repositories that use numbered files (e.g., documentation chunks, migrations, or ordered assets).
Expected behavior
It would be helpful if GitHub supported natural sorting (numeric-aware sorting), so the order would be:
...
Why this matters
Workarounds and limitations
A common workaround is to use zero-padding:
...
However, this approach has limitations. For example, when the total number of files grows (e.g., exceeding 100), filenames must be manually adjusted (e.g.,
001,002, ...), which can be inconvenient and error-prone. While not always a frequent scenario, it adds unnecessary friction.Possible solutions
Thanks for considering this!
Beta Was this translation helpful? Give feedback.
All reactions