static function doMerge($a, $cmp, $from, $pivot, $to, $len1, $len2)
 {
     $first_cut = null;
     $second_cut = null;
     $len11 = null;
     $len22 = null;
     $new_mid = null;
     if ($len1 === 0 || $len2 === 0) {
         return;
     }
     if ($len1 + $len2 === 2) {
         if (call_user_func_array($cmp, array($a[$pivot], $a[$from])) < 0) {
             haxe_ds_ArraySort::swap($a, $pivot, $from);
         }
         return;
     }
     if ($len1 > $len2) {
         $len11 = $len1 >> 1;
         $first_cut = $from + $len11;
         $second_cut = haxe_ds_ArraySort::lower($a, $cmp, $pivot, $to, $first_cut);
         $len22 = $second_cut - $pivot;
     } else {
         $len22 = $len2 >> 1;
         $second_cut = $pivot + $len22;
         $first_cut = haxe_ds_ArraySort::upper($a, $cmp, $from, $pivot, $second_cut);
         $len11 = $first_cut - $from;
     }
     haxe_ds_ArraySort::rotate($a, $cmp, $first_cut, $pivot, $second_cut);
     $new_mid = $first_cut + $len22;
     haxe_ds_ArraySort::doMerge($a, $cmp, $from, $first_cut, $new_mid, $len11, $len22);
     haxe_ds_ArraySort::doMerge($a, $cmp, $new_mid, $second_cut, $to, $len1 - $len11, $len2 - $len22);
 }