Sorter: sort order via flow variable

How can I set the Sorter nodes Sort order via flow variable? It expects a boolean array but I don’t see any node that always creating such a boolean array (or any array flow variable).

Hi,

Something like that could do the trick :demousers.knwf (913.5 KB)

In the group by nodes, note (I have forgotten it in the second case that option “retain row oder” must be activated). But the create collection column of Ipazin is more direct !

2 Likes

Hi @beginner,

to create an array of Boolean values I would use Table Creator with true of false inputs in first row followed by Create Collection Column and Table Column to Variable nodes.

Br,
Ivan

3 Likes

First an update, I only have 1 column in the sorter and using a boolean variable can be used to the the sort order and it works BUT:

I simplified the question too much. The core issue is that sorting ASC or DESC is ultimately decided by a different user input. (Regression performance metric: R2 -> sort desc, RMSE -> sort ASC etc). Therefore I would need to set the boolean variable in a Rule engine or Java snippet which doesn’t seem to work (Limitation: knime 4.1.3)

Hi @beginner,

I see. I would take this approach:
SortOrder

where you need to obtain user input in flow variable and transform it to table upon which sorting order is determined in Rule Engine node.

Br,
Ivan

2 Likes

But the rule engine node doesn’t allow generation of boolean column (or variable) because I already tried this with the Rule Engine (Variable) node. The Sorter node for sortOrder requires a boolean or boolean array.

Hi @beginner,

Rule Engine node does create Boolean columns.

$test$ = 2 => TRUE
$test$ = 1 => FALSE

Rule Engine Variable (yet) does not.

Br,
Ivan

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.