Hi there,
I'm currently writing a Java slideshow application to replace the
default image-viewing program in Windows. I want this program to sort
files the same way that Windows does, but I'm finding that emulating
this behavior is extraordinarily tricky, especially when one takes
miscellaneous symbols into account. Can you provide the precise
methodology Windows uses to sort its files? I only need the "by-name"
sorting process, as the other sorts are straightforward.
Here's what I already know:
* Upper-case letters are treated the same as lower-case.
* Numbers in filenames are sorted numerically, not alphabetically
(e.g. a9.txt comes before a10.txt).
* Ascii symbols are NOT sorted in ascii order, and in fact this order
CHANGES depending on where in the filename the symbols exist! When
the symbols appear at the beginning of the filename, the sorting order
seems to be:
[space] ! # $ % & ( ) , . ; @ [ ] _ ' - ` { } ~ + =
though I could be mistaken on one or two of these, as I gave up in
frustration during this process. =) Again, this only applies when
these characters are at the head of the file and are thus being sorted
on their own; once you embed them into alphanumeric strings everything
goes haywire. Example: "aab.txt" < "-ab.txt" < "a-b.txt" !!!
Seriously, try it out. It's insane.
At this point it seems like I'd have to put in hours of work
generating every possible permutation to get the ordering right, and I
really don't want to do that; but on the other hand, I'm so obsessed
with this problem now that I don't think I'm going to get any sleep
without having asked someone about it. Please help! |