I have a custom ArrayList. I need to re-arrange this ArrayList in particular order with respect to an integer Array. E.g
List<String> test = new ArrayList();
test.add("red");
test.add("green");
test.add("blue");
int [] X = {2,0,1};
Re-arrange this arrayList w.r.t X array. i.e item at 2nd index should come to 1st, 0th item to 2nd position and 1st item to 3rd position
Output should be:
blue
red
green
I know how to do it using for loop just want to know if there is any better solution then this.