a friend of mine has been taking notes of animal sounds that he hears during the day. Unfortunately, he is a bit of an oddball and he has no watch nor a smartphone, so he doesn’t know the exact time. But writing down the general time of day is good enough for him:
My friend distinguishes between the animals that make an “o” sound and the ones that do not. He finds the Rule Engine a bit too complex, but he has an easier solution:
It works, but… uh-oh! The order is now messed up.
But hey! There is a Sorter node. Just sort according to the row key. Problem solved! Or… is it?
My point is, I don’t know of an easy way to use the default row IDs to return a table to its original order. In the extremely silly example that I give above, I would have to make a new Integer column containing row indices and sort according to that. This is quite cumbersome; look for example in the more realistic example that I gave in the past:
Hi @Aswin , thank you for bringing this up, it’s always been an issue for me too, to the point that I do not rely on it at all. Hopefully the Knime team can look into this.
The workaround that I use is to create my own sort column, using the Counter Generation node:
Obviously, it’s the Concatenation that gives you the results that you got, so I’ll use the Row Splitter and Concatenate as you did, instead of using the Rule Engine, and the Counter Generation:
Input:
Results:
Of course you can filter out the Sort Order column, but I’d do that only if I’m at the end of the workflow, in case I need to re-sort further down the workflow.
Thank you @bruno29a , I often did something like this, except that I always used a Math Formula node that simply returned the row index as an integer column. I never considered using the Counter Generation node for this, but it is much more elegant, as it is immediately obvious what is happening.
Alternative/additional feature suggestion: the “create a new one” option in the RowID node could have an additional “Sortable” option that generates “Row042”-style row IDs (with preceding zeros). The result would be identical to the component in my earlier post, but without having to internally create and then remove an additional column.
good things come to those who wait: on behalf of our developers (thanks to @hotzm !), I’m happy to announce that a lexicographic search has been implemented in the sorter node, the table view, and most other places where sorting is done. Of course, backward compatibility is not broken, so e.g. the GroupBy/Pivot Nodes still sort strings the old fashioned way. Also, this was already available in 4.7.0 in case you didn’t notice Check it out in the new KNIME Version 4.7.1!