private void binarySplitSort ( List < ? extends SpatialComparable > objs , final int start , final int end , int depth , final int numdim , int [ ] dims , Sorter comp ) { final int mid = start + ( ( end - start ) >>> 1 ) ; // Make invariant comp . setDimension ( dims != null ? dims [ depth ] : depth ) ; QuickSelect . quickSelect ( objs , comp , start , end , mid ) ; // Recurse final int nextdim = ( depth + 1 ) % numdim ; if ( start < mid - 1 ) { binarySplitSort ( objs , start , mid , nextdim , numdim , dims , comp ) ; } if ( mid + 2 < end ) { binarySplitSort ( objs , mid + 1 , end , nextdim , numdim , dims , comp ) ; } }
Sort the array using a binary split in dimension curdim then recurse with the next dimension .