Welcome to the Invelos forums. Please read the forum rules before posting.

Read access to our public forums is open to everyone. To post messages, a free registration is required.

If you have an Invelos account, sign in to post.

    Invelos Forums->DVD Profiler: Desktop Technical Support Page: 1 2  Previous   Next
Sort title only looking at first character in a title starting with numbers.
Author Message
DVD Profiler Desktop and Mobile RegistrantAgrare
Registered: May 22, 2007
Reputation: High Rating
United States Posts: 1,033
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
Quoting Jykke:
Quote:
Quoting Agrare:
Quote:
I mean, even Microsoft sorts including The, A, etc and treating numbers (10 before 9) as their string and not a number. Thats why you see sequential titles (think tv episodes, comics) numbered 01 and not 1 (or 001).


Actually it is not how Microsoft sorts. At least in Windows XP Explorer files titles starting with numbers are sorted by their numerical order (the silly way to me).



mine has never done that, this is a vista machine so i'd need to do it on a different machine to post an image. I know I saw an option at one point (thought it was new to vista but may have been in xp) for Smart Sorting (I believe thats what is was called) I never played with the setting to see if it did what I speculated (sorting the names as you show). Do you perhaps have that set?

-Agrare
DVD Profiler Desktop and Mobile RegistrantAgrare
Registered: May 22, 2007
Reputation: High Rating
United States Posts: 1,033
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
Quoting smeehrrr:
Quote:
Quoting Agrare:
Quote:
I wouldn't hold your breath as far as changing thats concerned. In order to change it Ken would have to write his own sort algorithm that would parse the title, find those starting with numbers, convert the String representation of that number to an actual number, sort those numerically first, then take the remaining titles (the ones that don't start with a number) and sort those.

Actually I think it would be fairly trivial to write a comparison operator that handled numbers this way.  Five lines of code or so.  You don't need a new sort algorithm or two passes or anything.  All you need to know is that "20" < "100" < "A".


your 'comparison operator' is a new sort. Unless your talking about overloading the greater than and less than operators for a string, which could work. Which would probably be simpler than doing a full compare (and I admittedly didn't think about) but it I believe it would still require a bit more than 5 lines of code.

its not as simple as "20" is less than "100", because that doesn't tell me where "21" fits in, or where "201" fits in. The first character is always compared to the first character. So in all of those cases its "2" compared to "1". So depending on whats after the two (and not just the next character but it could come down to the last character in the string) depends on if "2" is less than "1" or if its greater than "1".

This is why padding with 0's works. "0" is always less than "1", "2" etc. by padding it with zeros, we putting the characters that we want to compare to each other in the same relative position in the String.

-Agrare
DVD Profiler Desktop and Mobile RegistrantStar ContributorJykke
Registered: March 13, 2007
Finland Posts: 413
Posted:
PM this userVisit this user's homepageDirect link to this postReply with quote
Quoting Agrare:
Quote:
mine has never done that, this is a vista machine so i'd need to do it on a different machine to post an image. I know I saw an option at one point (thought it was new to vista but may have been in xp) for Smart Sorting (I believe thats what is was called) I never played with the setting to see if it did what I speculated (sorting the names as you show). Do you perhaps have that set?

-Agrare


No, I have done nothing in order to get that sorting (at least I can't remember doing anything... which mean I did not - knowingly). Didn't even know there is a setting for this.
DVD Profiler Desktop and Mobile RegistrantStar ContributorDJ Doena
Registered: May 1, 2002
Registered: March 14, 2007
Reputation: Highest Rating
Germany Posts: 6,741
Posted:
PM this userEmail this userVisit this user's homepageView this user's DVD collectionDirect link to this postReply with quote
German XP Pro SP2, never changed a setting regarding ordering:

Karsten
DVD Collectors Online

DVD Profiler Desktop and Mobile RegistrantStar ContributorJykke
Registered: March 13, 2007
Finland Posts: 413
Posted:
PM this userVisit this user's homepageDirect link to this postReply with quote
Quoting DJ Doena:
Quote:
German XP Pro SP2, never changed a setting regarding ordering:



It appears that the default sort order in Windows XP was changed in SP1 to the sorting I showed in my picture. See: http://support.microsoft.com/kb/319827

Therefore your setting has been changed somehow. Check if you have the registry value NoStrCmpLogical which is described in the KB-article. If you have it, then it was added later since it is not included in a clean XP SP2 installation.
DVD Profiler Unlimited Registrantsmeehrrr
Registered: March 26, 2007
Posts: 196
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
Quoting Agrare:
Quote:

your 'comparison operator' is a new sort. Unless your talking about overloading the greater than and less than operators for a string, which could work. Which would probably be simpler than doing a full compare (and I admittedly didn't think about) but it I believe it would still require a bit more than 5 lines of code.

Of course it isn't a new sort.  Do you have any background in computer science or are you just spouting off?
Quote:

its not as simple as "20" is less than "100", because that doesn't tell me where "21" fits in, or where "201" fits in.

If all the characters up to the first whitespace are digits (or commas, I suppose) in both strings to be compared, then convert that to a numeric value and use it as your sort key.  If only one of the strings has the first word as digits, then that is less than the other string.  If neither string has a first word of digits, compare as usual.  Apply this comparison operator to your favorite sort algorithm.
Quote:

The first character is always compared to the first character. So in all of those cases its "2" compared to "1". So depending on whats after the two (and not just the next character but it could come down to the last character in the string) depends on if "2" is less than "1" or if its greater than "1".

Yes, that's how it's currently implemented, but that has nothing to do with the complexity of implementing it differently.
DVD Profiler Desktop and Mobile RegistrantAgrare
Registered: May 22, 2007
Reputation: High Rating
United States Posts: 1,033
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
Quoting smeehrrr:
Quote:
Quoting Agrare:
Quote:

your 'comparison operator' is a new sort. Unless your talking about overloading the greater than and less than operators for a string, which could work. Which would probably be simpler than doing a full compare (and I admittedly didn't think about) but it I believe it would still require a bit more than 5 lines of code.

Of course it isn't a new sort.  Do you have any background in computer science or are you just spouting off?


I am well experienced in computer science. Do you have any background in it? How about in reading comprehension? If you read the next sentence it starts off "Unless" and goes on to say if your talking about overloading the less than and greater than operator. That would mean, if that is in fact what your talking about, I am negating my previous statement of it being a new sort. I then go on to say it would probably be simpler and I hadn't thought about that approach.

but if you want to get technical, overloading the operator (changing how it determines if a string is greater than or less than another string) is a new sort because its not the old sort method. Yes, you would still then just call the sort function on your array containing titles (or whatever other object you are using to hold the titles) but that sort function would than be applying your new standards of greater than and less than, just as if you had manually written the code to loop through the strings and sort them (the new sort algorithm) Either way, there is an algorithm involved.

Quote:

Quote:

its not as simple as "20" is less than "100", because that doesn't tell me where "21" fits in, or where "201" fits in.

If all the characters up to the first whitespace are digits (or commas, I suppose) in both strings to be compared, then convert that to a numeric value and use it as your sort key.  If only one of the strings has the first word as digits, then that is less than the other string.  If neither string has a first word of digits, compare as usual.  Apply this comparison operator to your favorite sort algorithm.
Quote:



and what if the title is Attack of the 300 Foot woman? if I compared that to Attack of the 1000 foot gorilla (the second being a made up title) using your above method, guess which would come first? Yup, Attack of the 1000 foot gorilla, because the number is not the first character. Plus, that puts the number starting at the same character position in both strings, that is not necessarily the case. Unless your suggesting that we only sort numbers as numbers when they are the first character.

Quote:

The first character is always compared to the first character. So in all of those cases its "2" compared to "1". So depending on whats after the two (and not just the next character but it could come down to the last character in the string) depends on if "2" is less than "1" or if its greater than "1".

Yes, that's how it's currently implemented, but that has nothing to do with the complexity of implementing it differently.


See my Attack of the ... example to see how it does affect the complexity.

Anyway, I'm not saying that its not doable, all I'm saying is that I think your taking an overly simplistic approach to the problem, that would ultimatly not hold up because its not that simple a problem (if it was that simple Microsoft and other computer companies would have implemented it long ago and it wasn't until recently that I even saw the option that I guessed might do it. Though Jykke's post has introduced the fact that all my computers may be operating using non default sort methods after a fresh default install which I will look into and comment on later if I find out anything)
However, back to what I was saying. While I feel that you're approach is overly simplistic, I admit that I may be overcomplicating it and perhaps the truth of the situation lies somewhere in the middle.


Both of my posts dealt with the complications of such a sort, not the feasibility of it. I simply pointed out that I think its more complicated than non programmers would believe. You said you disagree and I responded with some additional reasoning on why I think its more complex than you think. Your response to that was to call into question my knowledge in the field, I tried to keep my post as non technical as possible so that non programmers would follow it and possibly understand why it is as it is, if you have some experience in the computer science field (as you seem to be suggesting by calling me out on my experience) you would have noticed that, even though i tried to keep it simple, I still used a couple terms that are common to the field. Additionally, if you had check my profile (as I did yours before I responded to your initial post) you would see that I list my occupation as programmer (which I admittedly could be lying about but why) that should hint to you that I may have a clue as to what I'm talking about)

My job causes me to constantly have to out-think the actions of users for the stupidest of errors, so I have to look for holes in my own thought process and try to see how others will interact with my code, which is not an easy task since when I use it I know what its supposed to do and that can subconsciously guide my actions. So I see some holes in your approach and pointed them out, that's no reason to insult my knowledge. I actually said I hadn't thought about overloading the operator, and that could simplify the problem, but you apparently didn't see that and chose to insult me.

-Agrare
DVD Profiler Desktop and Mobile RegistrantAgrare
Registered: May 22, 2007
Reputation: High Rating
United States Posts: 1,033
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
Quoting Jykke:
Quote:
Quoting Agrare:
Quote:
mine has never done that, this is a vista machine so i'd need to do it on a different machine to post an image. I know I saw an option at one point (thought it was new to vista but may have been in xp) for Smart Sorting (I believe thats what is was called) I never played with the setting to see if it did what I speculated (sorting the names as you show). Do you perhaps have that set?

-Agrare


No, I have done nothing in order to get that sorting (at least I can't remember doing anything... which mean I did not - knowingly). Didn't even know there is a setting for this.


Ok, I just did some testing, and I'm getting the same sorting behavior on my XP Desktop as Jykke posted.

The smart sorting option I refered to (may have been called Logical Sorting) I only recall seeing but could not locate it just now while searching for it (on either XP or Vista). I believe I saw it on my vista machine but its possible that since I reinstalled, the settings are slightly different preventing me from finding it, also it generally takes me awhile to refind stuff like that and remember where it is after I first find the setting. Of course it seems that there is no need to turn the setting on (if it does exist and I wasn't hallucinating) anyway as it is the default behavior.

When I followed the link to the knowledge base article, i was able to add the registry setting to make it behave like I remember. Since I (believe I) first noticed this (sorting 1, 10, 2) after dealing with MP3's and numbering them by track, and since then adopted the padding with 0's numbering scheme, its possible than when the change was put into Service Pack 1 (which appears to have been publically released Sept 9th 2002 based on some google searches) I just never noticed the sort was 'fixed' since I was now accustomed to using extra zeros.

Which I will still continue to use, because I like the look (for files anyway) of:

09 Filename
10 Filename

vs

9 Filename
10 Filename

-Agrare
DVD Profiler Desktop and Mobile RegistrantStar ContributorDJ Doena
Registered: May 1, 2002
Registered: March 14, 2007
Reputation: Highest Rating
Germany Posts: 6,741
Posted:
PM this userEmail this userVisit this user's homepageView this user's DVD collectionDirect link to this postReply with quote
Another remakr: I don't think that Ken is ordering manually. I suppose that he either uses the ordering ability of the underlying database or some built-in sort function in Delphi.
Karsten
DVD Collectors Online

DVD Profiler Desktop and Mobile Registrantlmoelleb
Beer Profiler now!
Registered: March 14, 2007
Denmark Posts: 630
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
Sorting in general is hugely complex and never something a developer should even consider trying to do on his own due to all the local variations. Let the OS (or a modern Framework like .NET or Java) do the sorting making sure it knows the locale to apply the rules from. If the developer does it on his own it goes as bad as - well - as bad as DVD Profiler (though I do not know if the byte comparison is implemented by Ken, Delphi, or the database... it is unfortunately still a standard mistake that happens all the time).

This specific modification for numbers is pretty easy though (think first year CS student assignment), as long as the OS/Framework sort algorithm is used for comparisons of actual strings, and people are allowed to turn it of if it interfears with their non-Western numbers... and in case someone thinks the sorting of numbers within the string would end up wrong (I do not consider one better than the other... as I use neither, for example my sort title of "50 first dates" is "Fifty first dates").

(and yes, I am an experienced software developer, and have 8 years experience specifically dealing with I18N as well since people tend to bring it up here)
Regards
Lars
DVD Profiler Unlimited Registrantsmeehrrr
Registered: March 26, 2007
Posts: 196
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
I probably shouldn't post when I'm in a bad mood.  Agrare, sorry if you took offense at my tone.  I've been a professional software developer for 17 years, and I still think your assessment of the complexity of this change is off base, but there's no need for me to be snippy about it.

To address your concern about numbers in the middle of the string, I'd say two things:  First, I probably wouldn't bother to fix that, because I don't believe it happens in practice.  Second, if I did decide to fix it, I'd change my comparison routine to compare word by word instead of character by character, using the same comparison rules for numbers that I outlined above. 

Using any reasonably modern software design, this change should be fairly trivial.  That said, as Lars points out, Ken is probably using Delphi to do the sort, and Delphia has all sorts of limitations due to its age.  It may not be practical to implement this sort of change in that environment.
    Invelos Forums->DVD Profiler: Desktop Technical Support Page: 1 2  Previous   Next