From b63350dc5823865531859ecba8659f9c68195a3f Mon Sep 17 00:00:00 2001 From: Sarvar <56576654+sarvar-akbarov@users.noreply.github.com> Date: Sat, 1 Jul 2023 19:17:12 +0600 Subject: [PATCH] Added solution in PHP language --- solutions/032.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/solutions/032.md b/solutions/032.md index 557cd73..5d45577 100644 --- a/solutions/032.md +++ b/solutions/032.md @@ -65,7 +65,7 @@ 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: @@ -73,4 +73,21 @@ class Solution: 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.