Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

'Name' sorting needs natural sort order of numbers #218

Open
insomniacUNDERSCORElemon opened this issue Jan 19, 2017 · 3 comments
Open

'Name' sorting needs natural sort order of numbers #218

insomniacUNDERSCORElemon opened this issue Jan 19, 2017 · 3 comments
Labels

Comments

@insomniacUNDERSCORElemon

Currently it's just alphabetical, leading to filenames without leading zeros to be improperly ordered.

Instead of 1, 2, 3, ...10 it's 1 10 2 3.


You can rename your files to a proper naming scheme, but this is a headache.

If there are any special characters or spaces in the file names, it can be trouble trying to figure out how to even process them to remove the offending characters.

The leading zeros need to be in proper amount (eg 001 through 099 ... or 0001 through 0462) so the best way to do this is with a loop... but this ALSO has to have proper numeric ordering, otherwise there is still an issue. I recently started having that issue with for in, the result is that you need to do something like this:

for a in ls * | sort -V; do

which brings up the issue that ls is recursive with just a wildcard, however that can be fixed by specifying more (for instance *.jpg).

TL;DR: it's a lot of reading around and tinkering to try and fix something that shouldn't really be an issue.

@Vladimir-csp
Copy link

The term you're looking for is natural sorting (represented with sort -n. sort -V is for version number sorting).

@insomniacUNDERSCORElemon insomniacUNDERSCORElemon changed the title Need proper alphanumerical sort order 'Name' sorting needs natural sort order of numbers Mar 20, 2017
@oferkv oferkv added the Bug label Jan 15, 2018
@xaxazak
Copy link

xaxazak commented Jul 31, 2018

I'd just like to add that the current "pure alphabetical" sort behavior is my preferred behavior (natural sorting can mis-sort some schemes, such as hashed names or key prefixes that get ignored, etc). It's also a preferred behavior for many developers in some areas (eg, file browsers). However, I'd be happy to see natural sorting as an option (even as default), as long as "pure alphabetical" was available.

@sandsmark
Copy link
Collaborator

this should be fixed by this: 6c8a2f7

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

No branches or pull requests

5 participants