0

How can we sort the values of one array using second array?

Input: String array1[] ={"a","b","c","d","e","f","g","h","i"} Int array2[]= {0,1,1,0,1,2,2,0,1} OUTPUT should be; {"a","d","h","b","c","e","i","f","g"}

21st Jun 2019, 3:33 PM
Saumya Upadhyay
Saumya Upadhyay - avatar
1 Réponse
0
Its not a trivial thing at all... And the possible solution depends heavily on which java version you have. It involves some conversion to lists, using Collections.sort() and implementing Comparator interface. Check this code and follow the link inside to stackoverflow.. This is just one of many possible solutions. https://code.sololearn.com/cp1S2bz9W9v8/?ref=app
21st Jun 2019, 6:26 PM
Tibor Santa
Tibor Santa - avatar