outline-style sorting algorithm

Michael Geary Mike at DeleteThis.Geary.com
Mon Apr 19 16:44:36 EDT 2004


Terry Reedy wrote:
> It it a well known problem that left-justified variable-length
> number representations in strings do not sort well when the
> strings are sorted in the standard manner.  Even without dots,
> directory listings will give you
>
> file1
> file10
> ...
> file19
> file2
> file20
> ...
> file29
> file3
> etc.

Interestingly enough, in Windows XP, Windows Explorer lists these files in
numerical order:

file1
file2
...
file9
file10
file11
...
file19
file20
file21
...
file29

The DIR command CMD.EXE still sorts alphabetically, but DIR in the 4NT
command shell from www.jpsoft.com displays the files in numerical order,
with a command line option to use alphabetical order instead.

It would be nice if more OS shells sorted filenames like this.

-Mike





More information about the Python-list mailing list