[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Repobrowser - Numeric order filename sorting

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: 2006-04-12 20:21:11 CEST

Gerasimov, Ivan wrote:
> Hello, Stefan!
>
>> But I had to modify the function. You see, compare functions don't
>> just return true/false, they have to return a tri-state value. Most
>> compare functions therefore return -1 for 'less than', 0 for
>> 'equal' and 1 for 'greater than'. The reason is that sort functions
>> need it that way to work faster.
>
> Yes, I see that. I've been testing the sample function with STL's
> sort, that's why I made it return Boolean.

Now I'm confused. How can stl sort something without knowing what's
'higher' and what's 'lower'? By simply knowing what's equal and what's
not, you can't sort. Or am I missing something here?
Are you sure the stl sort doesn't use some other means to check what's
greater? Maybe an overloaded '<' or '>' operator?

>> Now, your new function doesn't work. It first looked like it did,
>> then I tried the Subversion tags folder. Here the sorting failed.
>
> That's surprising! I've tried to test as heavily as I could, before I
> posted it.

I've tried it with the repobrowser on the Subversion tags folder. There,
you'll see that 0.37 comes *after* 0.6 and 0.7 (it's only the 0.37
that's wrong, all others are sorted correctly). Strange, I know, but I
haven't found out why yet.

> It only checks for _leading_ zeros. To make sort order more stable, I
> decided to place string with same numeric value but with less leading
> zeros earlier. The number with leading zeros looks bigger after all
> :-)

I see. Thanks for the explanation.

>> Also, you don't really parse the numbers anymore. In the first
>> function, you 'parsed' the numbers into real integers like this:
>> y_num = 10 * y_num + *str2_tmp - '0';
>
> Yes, I've mentioned that in my letter:
>
> IG>> Additionally, I eliminated the need to convert literal number to
> IG>> integer. This way, huge numbers that will not fit into int can
> be IG>> compared. All the comparisons are done with the
> CompareString() IG>> function from WinAPI.

Ops. I missed that. Sorry.

>> Maybe you can just start over from where I put your first function
>> (modified):
>> http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/src/TortoiseProc/Utils.cpp
>> (at the end, the static method CUtils::CompareNumerical()).
>
> I've already checked it out and started rebuilding it. As soon as I
> make it work, I'll post a patch.

No need to hurry. Take your time. It's not something that has to be
committed right now - it can wait until we release 1.4.0, and that's
still a long time until we do.

> Sorry for being a bit slow, have to do lots of other work at the same
> time :-(

Don't be sorry! I know the feeling, believe me :)

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.tigris.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Wed Apr 12 20:21:32 2006

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.