PHP Sort a multidimensional array by date start, or if uquals, by date end

I need to sort an array containing a date start and a date end.

To sort by date start I use this function:

usort($array, function($a, $b) {
  return new DateTime($a['datetime']) <=> new DateTime($b['datetime']);
});

but in case an element has the same date start to another one, i need then sort by date end.
And don’t know how to do this. Anyt suggest?

Example array

$array = [
0 => [
        "id" => 1
        "start" => 2024-07-24 05:00,
        "end" => 2024-07-25 14:00
    ],

1 => [
       "id" => 2
        "start" => 2024-07-22 06:00,
        "end" => 2024-07-22 08:00
    ],

2 => [
        "id" => 3
        "start" => 2024-07-27 10:00,
        "end" => 2024-07-28 11:00
    ],

3 => [
        "id" => 4
        "start" => 2024-07-22 06:00,
        "end" => 2024-07-22 07:00
    ]

]

With my example I expected this order id: 4, 2, 1, 3 (because id 4 and 2 has same start, but id 4 ends before)