fork download
  1. import java.util.*;
  2.  
  3. class Example {
  4. static Integer[] getSortedIndexes(final long[] arr) {
  5. Integer[] indexes = new Integer[arr.length];
  6. for (int n = 0; n < indexes.length; ++n) {
  7. indexes[n] = n;
  8. }
  9. Arrays.sort(indexes, (left, right) -> Long.compare(arr[right], arr[left]));
  10. return indexes;
  11. }
  12. public static void main(String[] args) {
  13. long[] arr = {1983, 321, 63, 832, 455, 1466, 788, 25425, 1839};
  14. Integer[] indexes = getSortedIndexes(arr);
  15. System.out.println(Arrays.toString(indexes));
  16. }
  17. }
  18.  
Success #stdin #stdout 0.11s 4386816KB
stdin
Standard input is empty
stdout
[7, 0, 8, 5, 3, 6, 4, 1, 2]