3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['price'=>100, 'rank'=>3], ['price'=>55000, 'rank'=>4], ['price'=>500, 'rank'=>5], ['price'=>130, 'rank'=>3], ['price'=>25000, 'rank'=>4], ['price'=>50000, 'rank'=>4], ['price'=>120, 'rank'=>3], ['price'=>1000, 'rank'=>5], ]; $price = array_column($arr, 'price'); $rank = array_column($arr, 'rank'); // Sort the data with price descending, rank descending // Add $data as the last parameter, to sort by the common key array_multisort($rank, SORT_DESC, $price, SORT_DESC, $arr); echo '<pre>'; print_r($arr); die;

preferences:
30.24 ms | 406 KiB | 5 Q