Jan 21, 2014 at 11:02am UTC
Hey all,
So I'm trying to sort an array of 10 elements provided by the user. For Example:
Person 1: 5
Person 2: 3
Person 3: 9
etc etc...
I want it to also pair the value with the person. So it should read:
person 3: 9
Person 1: 5
Person 2: 3
Sort the values in descending order.
I can sort the array, but I cant get the Person number to pair with the value....
I apologize for the lack of code, it is at home and I am at work :/
Jan 21, 2014 at 11:56am UTC
The easiest way is to define a structure that contains the person's name (or number), and the value. Then have a single array of these structures. Sort the array based on the value of the person.
Jan 21, 2014 at 1:49pm UTC
Got it, I will try that!! Thank you sir.
Jan 21, 2014 at 11:43pm UTC
It worked thanks!! Took a while though.