Weird PHP usort behavior when key is not present

Recently I’ve came into a weird behavior of PHP usort and I would like to share it and maybe get an explanation on why this is happening.

If you try to usort an array and the key used for sorting is not present in any of the array elements, the order is kept only until the array has less or equal to 16 elements. If the array has more than exactly 17 elements, the usort functions messes everything.

I’ve made a code so you can test it yourself on w3schools. https://www.w3schools.com/php/phptryit.asp?filename=tryphp_func_usort

<!DOCTYPE html>
<html>
<body>

<?php
   function my_sort($a, $b) {
     return (int)$a['sort_order'] - (int)$b['sort_order'];
   }
   
   //populating test array
   $array = array();
   for ($i=0; $i < 18; $i++) { 
    $array[$i] = array(
     'title' => $i
     );
   }

   foreach ($array as $key => $value) {
     echo $key . "=>".$value['title'];
     echo "<br>";
   }

    echo "<br>";
    echo "<br>";
    usort($array,"my_sort");

    foreach ($array as $key => $value) {
     echo $key . "=>".$value['title'];
     echo "<br>";
    }

     echo "<br>";
     echo "<br>";
     echo "<br>";
     echo "LESS THAN 17 Elements order is maintened";
     echo "<br>";
     echo "<br>";
     echo "<br>";

     $array = array();
     for ($i=0; $i < 16; $i++) { 
     $array[$i] = array(
      'title' => $i
     );
     }

     foreach ($array as $key => $value) {
       echo $key . "=>".$value['title'];
       echo "<br>";
     }

     echo "<br>";
     echo "<br>";
     usort($array,"my_sort");

     foreach ($array as $key => $value) {
      echo $key . "=>".$value['title'];
      echo "<br>";
     }
  ?> 

  </body>
  </html>

Is there any possible explanation for this behaviour?

Tested on PHP 7.3 and 8.4, same behavior