We are about to switch to a new forum software. Until then we have removed the registration on this forum.
How can I sort values in a stringList on the first part, before a - token? I'm making a program, where I have a string list. In this list, I add a time (example: 3.78, 81.84, 8.83) and a word (letters!). I want to make Processing sort the times, so that he give me 3.78, 8.83, 81.84. But if I use the sort() command, processing sorts the list based on the words and NOT on the times. How can I make this correct?
Thanks in advance, DaDa
Answers
You should use FloatDict and its sortValues() method instead:
https://Processing.org/reference/FloatDict.html
https://Processing.org/reference/FloatDict_sortValues_.html
Thank you,
But I have one more question... How can I get an entry at a particular index of that floatdict? I want to have a command which does the same as the get() command of a Stringlist (so that you can say: I want the first/second one in the list).
Thanks in advance, DaDa
If you prefer to access those entry pairs by their numerical index order, you're gonna need to pull out both of their arrays w/ keyArray() & valueArray(): #:-S
Thank you very much!!!
If I use them, was number 0 of the keyArray combined with number 0 in the valueArray when they were 'twins' in the FloatDict?
So, for example... I have 'pancace, 5', 'egg, 10' and 'hamburger, 20' in a FloatDict. I use the keyArray AND the valueArray and after I've done that I have:
KeyArray: [0]=Pancace, [1]=Egg and [2]=Hamburger ValueArray: [0]=5, [1]=10 and [2]=20
Is this correct?
Thank you so much!!! Regards, Dada
Yes, that's it! They're gonna share the same index number. B-)
But if you don't need
float
values, use IntDict instead: ;)https://Processing.org/reference/IntDict.html
Okay, thank you very much. I'll now finish my sketch!
Regards, DaDa