05-27-2004 10:28 AM
05-27-2004 11:24 AM
05-28-2004 03:34 AM - edited 03-16-2022 01:35 PM
Strings are sorted alphabetically, even if they are numeric, thus 51 goes before 6, etc. same as "Hippopotamus" is smaller than "Mouse", even though the animal AND the "word" is bigger. 🙂
The "number strings" need to be converted to numeric representation (DBL, I32, etc.) as appropriate to get the correct order.
Your icon is very nice, but your code jumps through quite a few uneccessary hoops to achieve this relatively simple task. I have attached a streamlined version that does exactly the same with much simpler code, and sorts numerics if so desired as an option. 🙂 I use "Fract/Exp string to number" for more flexibility, if you only have integers, you could use "Decimal String to number" instead. Modify as needed.
I would also recommend to look into the OpenG toolkit. You will find an 2D sort VI that already is quite flexible (except for the numeric option). My code above is partially based on the openG algorithm.
Many improvements are possible. You might want to add error handling to prevent numeric sorting of non-numeric columns (e.g. column 0 in our case) or even add some extra intelligence. e.g. it could check if the desired column only contains numbers and no other characters, then switch to numeric mode automatically, while using alpha mode in all other cases.
Notice that Dennis's example above does not handle sorting by column 0, because it is not numeric. Since you have mixed fields, this will thus not be sufficient.
09-09-2004 12:53 PM
08-08-2013 05:03 AM
I have seen your vi and it is very useful to sort the row of the tables, based in just one column.
The problem I have, it is to sort the rows of a table in ascending order base in the column 0 and 1. Both columns could be converted to I32.
Example:
ID Test
120 1
120 2
120 3
121 1
122 2
--
--
Thanks for your help.
Simbani
01-14-2021 02:27 PM
Thanks for the clarification on strings-this was exactly what I needed and very much appreciated. I can finally stop banging my head against the wall.
Cheers!