4 lines Java


  • 1
    Arrays.sort(people, (a, b) -> (a[0] == b[0] ? a[1] - b[1] : b[0] - a[0]));
    List<int[]> list = new ArrayList();
    for (int[] p : people) list.add(p[1], p);
    return list.toArray(new int[people.length][2]);
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.