Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion solutions/032.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,29 @@ The sortTheStudents method takes a `list` of lists called `score`, where each in

In summary, the code sorts the `score` list of students based on a specific score index `k` in descending order. The time complexity is typically O(n log n), and the space complexity is O(1).

#### Ptyhon3
#### Python3

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

#### PHP
```php
class Solution {

/**
* @param Integer[][] $score
* @param Integer $k
* @return Integer[][]
*/
function sortTheStudents($score, $k) {
uasort($score, function ($studentA, $studentB) use($k) {
return ($studentA[$k] > $studentB[$k]) ? -1 : 1;
});
return $score;
}
}
```
***NB***: If you want to get community points please suggest solutions in other languages as merge requests.