I am working in Java. I have two lists, let's call them A and B, which I want to sort.
A is an Integer list, so I have no problem to do that. I simply use Collections.sort()
to obtain a sorted list of integers.
The problem comes with the list B. I want to make the same changes done before in A.. B is a list of objects, but there's no way to associate the changes in B with changes in A. I mean, there's no condition to create a comparator method.
Little example:
I have:
A -> {5,1,3,6,4}
B -> {a,b,c,d,e}
I want to sort A and apply the same changes to B to obtain:
A -> {1,3,4,5,6}
B -> {b,c,e,a,d}
Is there any way to do that using built-in Java functions? I prefer to avoid writing a sorting algorithm myself because of efficiency. Thank you!