We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I have two arrays where one array represents a collection of names and the other describes their associated marks.I wanted to sort the marks inside the array in ascending order, and then also the respective names related to the marks.
My aim is to create a rank list.
float sum = 0;
String [] name = {"A", "B", "C", "D","E"};
float [] mark = {12, 2, 4, 6, 23};
void setup() {
size(600, 600);
smooth();
}
void draw() {
background(225);
fill(0);
println(name.length);
for (int i =0; i<name.length; i++) {
text(name[i] + ":"+ mark[i], 100, 100+i*50);
}
}
//// i wanted to sort it as E:23, A:12, D:6, C:4, B:2
It would be great if someone can help me with this. :)
Many thanks in advance, Yousuf
Answers
Take a peek @ Processing's IntDict and its sortValues() method: L-)
For descending order use sortValuesReverse() instead: :-B
Thank you @GoToLoop! I shall start reading about the mentioned references :)
This is awesome! @GoToLoop I have to learn these :) :)