Posted Mar 28, 2009 1:57 UTC (Sat) by foom (subscriber, #14868)
[Link]
> Sorting numerically in GNU ls is done by 'ls -v'.
Huh, never knew that, interesting! Never would have found that from the man page, which says
"-v sort by version". That seems a remarkably poor description of what it actually does.
> (By default, despite comments elsewhere in this thread, ls sorts
ASCIIbetically, so " 2" comes before "1".)
Well, not exactly: GNU ls has a default sort which depends on the locale's collation settings, and
most systems default to a locale like en_US.UTF-8, so most people have it sorting in a
case/accent-insensitive manner by default on their systems.
Leading spaces are common, actually
Posted Mar 28, 2009 20:36 UTC (Sat) by nix (subscriber, #2304)
[Link]
It's called 'sort by version' because the function it calls (strverscmp())
was designed to sort version numbers, and because the expected use of
ls -v was sorting a directory full of version-named directories in version
order.
(And you're right on the collation sort thing: I spoke carelessly.)