Sorting on RowID

I keep forgetting to raise this issue I sometimes get in workflows.

after various manipulations my table has often lost its original order, I.e. The RowIDs are no longer in their original order.

there is no node which can easily sort this out, ideally a Sort By RowID node is required. Which can intelligently sort on mixed text and numbers, I.e. Such that Row0, Row1, Row2, .... Row 10, Row11, .... Row100 appear in this order etc. and not Row0, Row1, Row10, Row2 ....

i appreciate there are some workarounds that can be done, such as using a Maths formula node to generate a ROWINDEX column, earlier in the workflow, then sort on this ROWINDEX column, but this is not always practical when certain manipulations are done, and it's fiddly and cumbersome.

any thoughts?

simon.

I agree, this would be quite nice.  Maybe a feature request for the sorter node (sort by RowID)?

 

 

Simon,

Fully with you, the legacy "RowID as messed-up string" is quite annoying. A (hidden?) rowindex in the default table model would be quite a thing to have for sorting (and joining?) purposes. 

Cheers
E

The hidden rowid sorting will break as soon as you concatenate two tables, because then these hidden rowIds won't be unique any more and don't really correspond to the visible row IDs any more. Also there may be other row ids, not generated by KNIME that have a similar format (i.e. "string"+"number").

We (actually Bernd ;-)) were thinking of the following solution for sorting:

  • The row id will be split into a string part at the beginning and an number part at the end
  • When comparing two row IDs, first the string part will be compared lexicograhically, and then the number part
  • If any part is missing in a row ID it will be treated as the empty string or -infinity i.e. smaller than any existing string or number, respectively.

Some examples:

ARow0
ZRow1
BRowNoNumber
112
ARow0
ZRow11
ZRow2
27

will be sorted as

27
112
ARow0
ARow0
BRowNoNumber
ZRow1
ZRow2
ZRow11

But also

Row3
Row4
Row22_1

would be sorted as

Row22_1
Row3
Row4

Does this come close to your expectations?