Custom Columns: Partial Strings are sorted incorrectly
Moderators: Hacker, petermad, Stefan2, white
Custom Columns: Partial Strings are sorted incorrectly
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.
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.
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
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
https://www.ghisler.com
Ah, bummer. It would be really usefull for me.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.
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();
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...

- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
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.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.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
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!
It's a little slower to do it that way, but it does work!
Licensed, Mouse-Centric, moving (slowly) toward Touch-centric
-
- Power Member
- Posts: 556
- Joined: 2006-04-01, 00:11 UTC
You could use a table conversion numberTOchar, which must provide right sorting in end effect.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.
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 ?
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
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
https://www.ghisler.com