code: function sort(values, boxes, indices, left, right) {
      if (left >= right) return;
  
      const pivot = values[(left + right) >> 1];
      let i = left - 1;
      let j = right + 1;
  
      while (true) {
          do i++; while (values[i] < pivot);
          do j--; while (values[j] > pivot);
          if (i >= j) break;
          swap(values, boxes, indices, i, j);
      }
  
      sort(values, boxes, indices, left, j);
      sort(values, boxes, indices, j + 1, right);
  }
docs: custom quicksort that sorts bbox data alongside the hilbert values