docs: public void sort(AttributeStreamOfInt32 indices, int begin, int end,
  			ClassicSort sorter) {
  		if (end - begin < 32) {
  			sorter.userSort(begin, end, indices);
  			return;
  		}
  		boolean b_fallback = true;
  		try {
  			double miny = NumberUtils.positiveInf();
  			double maxy = NumberUtils.negativeInf();
  			for (int i = begin; i < end; i++) {
  				double y = sorter.getValue(indices.get(i));
  				if (y < miny)
  					miny = y;
  				if (y > maxy)
  					maxy = y;
  			}
  
  			if (reset(end - begin, miny, maxy, end - begin)) {
  				for (int i = begin; i < end; i++) {
  					int vertex = indices.get(i);
  					double y = sorter.getValue(vertex);
  					int bucket = getBucket(y);
  					m_buckets.set(bucket, m_buckets.get(bucket) + 1);// counting
  																		// values
  																		// in a
  																		// bucket.
  					m_bucketed_indices.write(i - begin, vertex);
  				}
  
  				// Recalculate buckets to contain start positions of buckets.
  				int c = m_buckets.get(0);
  				m_buckets.set(0, 0);
  				for (int i = 1, n = m_buckets.size(); i < n; i++) {
  					int b = m_buckets.get(i);
  					m_buckets.set(i, c);
  					c += b;
  				}
  
  				for (int i = begin; i < end; i++) {
  					int vertex = m_bucketed_indices.read(i - begin);
  					double y = sorter.getValue(vertex);
  					int bucket = getBucket(y);
  					int bucket_index = m_buckets.get(bucket);
  					indices.set(bucket_index + begin, vertex);
  					m_buckets.set(bucket, bucket_index + 1);
  				}
  
  				b_fallback = false;
  			}
  		} catch (Exception e) {
  			m_buckets.resize(0);
  			m_bucketed_indices.resize(0);
  		}
  
  		if (b_fallback) {
  			sorter.userSort(begin, end, indices);
  			return;
  		}
  
  		int j = 0;
  		for (int i = 0, n = m_buckets.size(); i < n; i++) {
  			int j0 = j;
  			j = m_buckets.get(i);
  			if (j > j0)
  				sorter.userSort(begin + j0, begin + j, indices);
  		}
  		assert (j == end);
  
  		if (getBucketCount() > 100) // some heuristics to preserve memory
  		{
  			m_buckets.resize(0);
  			m_bucketed_indices.resize(0);
  		}
  	}