Answer the question
In order to leave comments, you need to log in
How to sort an array in a given order?
Greetings.
There is an array:
Array
(
[1] => Array
(
[Высшая] => 0
[Вторая] => 0
[Первая] => 0
)
[2] => Array
(
[Вторая] => 0
[Первая] => 0
[Высшая] => 0
)
[3] => Array
(
[Высшая] => 0
[Первая] => 0
[Вторая] => 0
)
[4] => Array
(
[Высшая] => 0
[Первая] => 0
[Вторая] => 0
)
[5] => Array
(
[Вторая] => 0
[Высшая] => 0
[Первая] => 0
)
)
Answer the question
In order to leave comments, you need to log in
I solved it clumsily, but it works:
$league_sort_order = array('Высшая', 'Первая', 'Вторая');
foreach ($league_sort_order as $league_sort_order_key => $league_sort_order_value) {
foreach ($tournaments_array as $tour_number_key => $tour_number_value) {
foreach ($tour_number_value as $league_key => $league_value) {
if ($league_value['players']) {
if ($league_sort_order_value == $league_key) {
foreach ($league_value['players'] as $player) {
usort($league_value['players'], "cmp_total");
$tournaments_array_sorted_by_league[$tour_number_key][$league_sort_order_value] = $league_value;
//$tournaments_array[$tour_number_key][$league_sort_order_value] = $league_value;
}
}
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question