void (final int[] indexes) { // the indexes are a discrete set of values that have no duplicates, // and describe the relative order of each of them. // as a result, we can do some tricks.... final int[] unsorted = indexes.clone(); Arrays.sort(unsorted); final Content[] usc = new Content[unsorted.length]; for (int i = 0; i < usc.length; i++) { usc[i] = elementData[indexes[i]]; } // usc contains the content in their pre-sorted order.... for (int i = 0; i < indexes.length; i++) { elementData[unsorted[i]] = usc[i]; } }