fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. public static class Run {
  12. public int points;
  13. public int runId;
  14. }
  15.  
  16. public static void main (String[] args) throws java.lang.Exception
  17. {
  18. int[][] points = new int[][] {
  19. new int[] {12, 13, 10, 0, 0, 0}
  20. , new int[] {1, 2, 3, 4, 5, 6}
  21. };
  22. Run[] runs = new Run[points[0].length];
  23. for (int i = 0 ; i != runs.length ; i++) {
  24. Run r = new Run();
  25. r.points = points[0][i];
  26. r.runId = points[1][i];
  27. runs[i] = r;
  28. }
  29. Arrays.sort(runs, new Comparator<Run>() {
  30. public int compare(Run a, Run b) {
  31. return -Integer.compare(a.points, b.points);
  32. }
  33. });
  34. for (int i = 0 ; i != runs.length ; i++) {
  35. points[0][i] = runs[i].points;
  36. points[1][i] = runs[i].runId;
  37. }
  38. for (int r = 0 ; r != 2 ; r++) {
  39. for (int i = 0 ; i != runs.length ; i++) {
  40. System.out.print(points[r][i]+" ");
  41. }
  42. System.out.println();
  43. }
  44.  
  45. }
  46. }
Success #stdin #stdout 0.07s 381248KB
stdin
Standard input is empty
stdout
13 12 10 0 0 0 
2 1 3 4 5 6