I have the following array depicting points accumulated during the year. As a tie breaker on equal points, I have another value that I calculate that I want the result to be sorted on.
This is the sorted array, showing points during the year:
$results = [
1 => 220
0 => 209
4 => 127
14 => 89
3 => 84
7 => 78
2 => 71
13 => 61
16 => 56
8 => 48
12 => 45
10 => 42
11 => 42
6 => 39
5 => 35
9 => 32
15 => 22
17 => 22
18 => 22
19 => 1
Because indexes 10 and 11, and 15, 17 and 18 are equal, they need to be sorted by the lowest values in the following array:
// For 10 and 11
$anotherArray = [
11 => 101
10 => 119
]
// For 15, 17 and 18
$anotherArray = [
17 => 150
18 => 160
15 => 179
]
So the resulting array should look like this:
$finalArray = [
1 => 220
0 => 209
4 => 127
14 => 89
3 => 84
7 => 78
2 => 71
13 => 61
16 => 56
8 => 48
12 => 45
11 => 42
10 => 42
6 => 39
5 => 35
9 => 32
17 => 22
18 => 22
15 => 22
19 => 1
]
How would I achieve this?