I need to sort an array in PHP and then sort it by the second index if the first index is the same. Let me explain:
Items will be randomly ordered:
(2,1),(4,4),(2,9),(4,8),(2,35),(2,1),(2,35),(4,4),(4,25),(4,4)
I need to sort them first by first number. therefore, the result will be:
(2,1),(2,9),(2,1),(2,35),(4,4),(4,8),(4,4),(4,25),(4,4)
Now you can see that all elements are grouped by the first index together. Now I need to group the current grouping by the second index "WITHIN". So it looks like this:
(2,1),(2,1),(2,9),(2,35),(4,4),(4,4),(4,4),(4,8),(4,25)
It was just a representation of an array. The actual array is below:
Array
(
[0] => Array
(
[practice_id] => 119
[practice_location_id] => 173
)
[1] => Array
(
[practice_id] => 2
[practice_location_id] => 75
)
[2] => Array
(
[practice_id] => 18
[practice_location_id] => 28
)
[3] => Array
(
[practice_id] => 119
[practice_location_id] => 174
)
[4] => Array
(
[practice_id] => 119
[practice_location_id] => 173
)
[5] => Array
(
[practice_id] => 2
[practice_location_id] => 75
)
[6] => Array
(
[practice_id] => 119
[practice_location_id] => 174
)
[7] => Array
(
[practice_id] => 18
[practice_location_id] => 28
)
[8] => Array
(
[practice_id] => 18
[practice_location_id] => 27
)
)
It would be very helpful to help.