I have a problem sorting some arrays because some comparing values are the same and usort can't be controlled in which order those should be returned. This is a limitation of usort which I can't overcome unless I use some custom sorting function. This is where I need the help.
I have this array:
Array
(
[0] => Array
(
[date] => 23/01/2021
[time] => 15:25
[name] => name1
)
[1] => Array
(
[date] => 23/01/2021
[time] => 15:27
[name] => name2
)
[2] => Array
(
[date] => 26/01/2021
[time] => 07:19
[name] => name3
)
[3] => Array
(
[date] => 26/01/2021
[time] => 07:24
[name] => name4
)
[4] => Array
(
[date] => 27/01/2021
[time] => 08:38
[name] => name5
)
[5] => Array
(
[date] => 27/01/2021
[time] => 08:38
[name] => name6
)
[6] => Array
(
[date] => 27/01/2021
[time] => 10:09
[name] => name7
)
[7] => Array
(
[date] => 27/01/2021
[time] => 16:40
[name] => name8
)
)
I want to sort the array in chronologial order (newest to oldest) but as you can see name5 and name6 have the same date and time. I want these to be returned in the order they appear (the smallest key first).
What I would like as an outcome for example in this specific array is a reverse order (since they are in oldest to newest) but name5 and name6 not to be reversed (because I want to keep the order they are in).
How can I do this? Not specifically for this table, but maybe on another table where 3 items have the same date/time.
Thanks