Custom Columns: Partial Strings are sorted incorrectly

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
MarcoPolo
Junior Member
Junior Member
Posts: 2
Joined: 2009-01-09, 09:06 UTC
Location: Vienna, Austria

Custom Columns: Partial Strings are sorted incorrectly

Post by *MarcoPolo »

Steps to reproduce behavior:

Add a custom column and display only parts of the string, e.g. [=tc.name:6-].

Then try to sort on this column -> the sort order will always be dependent on the full column (in this case tc.name) and not on tc.name starting from the 6th character.

It seems that the program sorts first and then performs the string operation instead of the other way around. It would be more natural to sort the displayed values instead of the values in the background.
User avatar
Hacker
Moderator
Moderator
Posts: 13067
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

MarcoPolo,
See please [Sugg] Sorting only according to shown values.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, currently not supported. I have tried to add it once in the past, but it leads to many problems (e.g. with numeric fields) and cannot be added easily.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

ghisler(Author) wrote:Sorry, currently not supported. I have tried to add it once in the past, but it leads to many problems (e.g. with numeric fields) and cannot be added easily.
So maybe it is possible to add feature for easy field types as strings?

P.S. I have no need in this feature.
MarcoPolo
Junior Member
Junior Member
Posts: 2
Joined: 2009-01-09, 09:06 UTC
Location: Vienna, Austria

Post by *MarcoPolo »

ghisler(Author) wrote:Sorry, currently not supported. I have tried to add it once in the past, but it leads to many problems (e.g. with numeric fields) and cannot be added easily.
Ah, bummer. It would be really usefull for me.

I understand the difficulty. If you care to elaborate, how did you implement your sorting algorithm?

I suppose you first do a sort based on the first field in the custom column, and then you parse the ":6-" in the string in order to create the displayed value.

Would it be too difficult to add another column to your data structure containing the truncated string and sorting this field alphanumerically, no matter what underlying base type it used to be?

You would fill and use this field for sorting only if the the following two conditions are met: The column that is being used for sorting is a custom column and contains string operations. I am assuming you have to make at some point the decision on what column you need to sort on, you would have to expand this code at this point only.

Something like:

Code: Select all

sortColumn = getSortColumnFromGUI();
if ((sortColumn.Type == customColumn) && sortColumn.ContainsStringOps)
{
  fillSpecialSortingColumn( sortColumn );
  sortColumn = specialSortingColumn;
}

sortColumn.sort();
And you would never display this field, thus keeping the current display logic the way it was.

I have no idea if this fits your architecture, but it is worth the try.

Thank you for answering the post and a big thanks for creating this great swiss army knife for file operations... ;-)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

If you care to elaborate, how did you implement your sorting algorithm?

I suppose you first do a sort based on the first field in the custom column, and then you parse the ":6-" in the string in order to create the displayed value.
When I tried to add it, I had to convert each field to text before sorting, which is a problem with numeric fields because sorting them alphabetically gives a completely wrong sort order.
Author of Total Commander
https://www.ghisler.com
User avatar
JohnFredC
Power Member
Power Member
Posts: 886
Joined: 2003-03-14, 13:37 UTC
Location: Sarasota Florida

Post by *JohnFredC »

In my code, I internally pad "text" numerics with leading zeros (and trailing zeros too, if decimals are involved) to fill a uniform field width before sorting. This "normalizes" the values and results in correct sorting.

It's a little slower to do it that way, but it does work!
Licensed, Mouse-Centric, moving (slowly) toward Touch-centric
Postkutscher
Power Member
Power Member
Posts: 556
Joined: 2006-04-01, 00:11 UTC

Post by *Postkutscher »

ghisler(Author) wrote:When I tried to add it, I had to convert each field to text before sorting, which is a problem with numeric fields because sorting them alphabetically gives a completely wrong sort order.
You could use a table conversion numberTOchar, which must provide right sorting in end effect.
Or introduce this feature at least for text fields. It would be better than nothing.
If it doesn`t fit to TC7.50 now, may I suggest this to TC7.51-TC7.52 ?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48088
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, I will not add it for now. Try e.g. [=tc.size:2-] - this would give strange sort results.
Author of Total Commander
https://www.ghisler.com
Post Reply