Feature suggestion: improved row key ordering

Dear Knimers,

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:

image

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:

image

It works, but… uh-oh! The order is now messed up.

image

But hey! There is a Sorter node. Just sort according to the row key. Problem solved! Or… is it?

image

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:

https://forum.knime.com/t/feature-request-generic-if-else-no-low-code-solution/26219/4?u=aswin

Therefore I suggest adding a “Natural ordering” (or whatever the technical term is) option to the Sorter node.

Best
Aswin

6 Likes

Hello @Aswin,

have added +1 to existing ticket (Internal reference: AP-3276)
(Love your examples :sweat_smile:)

Br,
Ivan

8 Likes

Meanwhile, people can use this component to convert the row IDs into a format that can be easily sorted:

image

In:
image

Table with new row IDs, correctly sorted after shuffling::
image

It should work for any number of rows.

Best
Aswin

KNIME_project15.knwf (14.0 KB)

2 Likes

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:
image

Results:
image

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.

And here’s how the workflow looks like:

Here’s the workflow:
Add ID or Sort Order to table.knwf (15.5 KB)

3 Likes

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.

1 Like

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.

Hey all,

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 :slight_smile: Check it out in the new KNIME Version 4.7.1!

Kind regards,
Lukas

8 Likes