Sort 2 arrays the same way, one int, one String

edited November 2016 in How To...

Hi

I have 2 arrays, one int, one string and I want to be able to sort them in exactly the same way

String[] animal = {"dog","cat","duck,","pig","cow"};
int[] score = {5,9,3,8,2};

I then proceed to sort score like this:

score = sort(score); 
score = reverse(score);

so score is now like {9,8,5,3,2}

I now want to sort animal the exact same way as if cat is bound to 9 and dog is bound to 5. How can I do this?

Answers

Sign In or Register to comment.