Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.17 KB

_2545. Sort the Students by Their Kth Score.md

File metadata and controls

48 lines (36 loc) · 1.17 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 24, 2024

Last updated : June 24, 2024


Related Topics : Array, Sorting, Matrix

Acceptance Rate : 85.59 %


Solutions

Java

class Solution {
    public int[][] sortTheStudents(int[][] score, int k) {
        Arrays.sort(score, new Comparator<int[]>() {
            public int compare(int[] a, int[] b) {
                return -1 * Integer.compare(a[k], b[k]);
            }
        });

        return score;
    }
}

Python

class Solution:
    def sortTheStudents(self, score: List[List[int]], k: int) -> List[List[int]]:
        return sorted(score, key=lambda x: x[k], reverse=True)