<?php
$alliances = [
['id' => 1, 'output' => '1', 'score' => 10],
['id' => 2, 'output' => '0', 'score' => 9],
['id' => 3, 'output' => '1', 'score' => 11],
['id' => 4, 'output' => '1', 'score' => 9],
['id' => 5, 'output' => '0', 'score' => 10],
];
array_multisort(...[array_column($alliances, 'output'), SORT_DESC, array_column($alliances, 'score'), SORT_DESC, &$alliances]);
var_export($alliances);
- Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
- array (
0 =>
array (
'id' => 3,
'output' => '1',
'score' => 11,
),
1 =>
array (
'id' => 1,
'output' => '1',
'score' => 10,
),
2 =>
array (
'id' => 4,
'output' => '1',
'score' => 9,
),
3 =>
array (
'id' => 5,
'output' => '0',
'score' => 10,
),
4 =>
array (
'id' => 2,
'output' => '0',
'score' => 9,
),
)
preferences:
61.86 ms | 408 KiB | 5 Q