Is it currently possible to apply natural sorting to Strings in KNIME, i.e. 1 < 2 < 10 and a1 < a2 < b1 < b2 etc?
There are lots of implementations of this in Java and in the past I've cobbled together meta-nodes that employ some of them. However, I was wondering if I'd missed an easier way.
If it ins't currently possible, could this be added as a feature of the Sorter node or as a new node?
Thank you for reporting this. At the moment you do not have something easier available to implement a natural sort. Our development team has this in the backlog for the next releases. We'll keep you posted on the progress.
I extend this thread with information about the current ‘Sort Node’ limitations.
Natural sorting in short, is a more human-friendly (“natural”) sorting,
it will sort a1, a2, a11
instead of a1, a11, a2 (alphabetical sorting).
(see natural sorting full definition)
Knime sorts strings alphabetically by default, and several issues arise because there is no a “Natural Sorter Node”.
The usual answer is to split the string into string and and numeric parts and then sort the table in a multi-column way, such as
If I want to sort all the blocks I would have to code a recursive algorithm to split strings and numbers (probably using regex) and then sort in the multicolumn way. Probably there are better alternatives, however a less obscure and proper solution from Knime may be adding the “natural sorting” option to the ‘Sorter Node’ capabilities, just as @rsherhod said.