I have the following problem: I have two arrays of a different data type, e.g.
byte[] a = {2,5,3};
long[] b = {2,0,1};
And I want b to get sorted and the entries in a must be changed respectively, s.t. I get
byte[] a = {5,3,2};
long[] b = {0,1,2};
I've seen that most people do that with a Comparator but that doesn't seem to work with different data types. I am looking for an efficient solution as the array lengths will be very large. However, a has only two different entries 0 and 1 (but I still want to keep it as byte to have the option for more entries) and all pairs (0,x) are already sorted (that means if I only pick pairs where the first entry is a 0 then it is already sorted). The same holds also for pairs (1,x'), but the entries in b are not completely sorted. I hope my problem got clear. I am happy for any suggestions.
Thank you very much in advance!
Edit: Apparently this question: Sort a parallel array using Arrays.sort() is very similar. However I wasn't able to reproduce any working example. Does anyone have a full working example?
byteand along, then a single collection/array of that type. Then you can just sort that collection/array using a comparator for that type.