On Thu, Mar 19, 2009 at 4:34 PM, Thomas Martitz
<[email protected]> wrote:
>> I've found a simpler solution for this. Trying the code raises the
>> following problem:
>>
>> 00 < 0b < 01 < 1
[...]
> Nautilus has this problem too. I don't know what windows does in this case.

I don't see any problem here. You just need to distinguish between
strings and values on sorting:
a. 00 -> value 0
b. 0b -> value 0, followed by string "b"
c. 01 -> value 1
d. 1 -> value 1

so while the strcmp() is the tie-breaker between c. and d.,  sorting
of a. and b. is also rather simple -- you sort by the leading numbers
first. This makes a. and b. come before the others. Then, as a. and b.
are a "starting with zero"-group you have to resort that again as
there is a tie with the numbers. Thus b. comes after a. That's how
ASCII-sorting would do it (and also how windows explorer does it).

You can't simply sort by leading numbers and ignore that the string
has other characters in it too.


 - Dominik

Reply via email to