Open insomniacUNDERSCORElemon opened 7 years ago
The term you're looking for is natural sorting (represented with sort -n
. sort -V
is for version number sorting).
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.
this should be fixed by this: https://github.com/oferkv/phototonic/commit/6c8a2f787c755aa090c6c9747e2a3781739a0ff0
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
; dowhich 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.