func (p VersionPtrs) radixSortDescent(tmp []*Version, keyIndex uint8) {
	if keyIndex >= maxKeyIndex {
		return // Nothing to sort anymore.
	}

	// The descent. Unlike this, multikeyRadixSort does only one run and hence
	// is able to read strides from its histogram ("offset[]").
	// As classical radix sort cannot (even if optimized to one run for the histogram),
	// the collection needs to be visited once more here.
	startIdx := 0
	lastValue := p[0].version[keyIndex]
	for i, v := range p {
		value := v.version[keyIndex]
		if lastValue == value { // Accumulate spans of the same value.
			continue
		}
		if i-startIdx < 2 {
			startIdx, lastValue = i, value
			continue
		}

		subslice := p[startIdx:i]
		if subslice.isSorted(uint(keyIndex + 1)) {
			startIdx, lastValue = i, value
			continue
		}

		residualLength := i - startIdx
		startIdx, lastValue = i, value
		switch {
		case residualLength < thresholdForResidualSort:
			sort.Sort(subslice)
		case keyIndex <= (maxKeyIndex - 2):
			subslice.multikeyRadixSort(tmp, keyIndex+1)
		default:
			subslice.radixSort(tmp, keyIndex+1, 32)
		}
	}
	// Capture trailer of same values (such as 250.100, 250.0).
	if residualLength := len(p) - startIdx; residualLength > 1 {
		subslice := p[startIdx:]
		if subslice.isSorted(uint(keyIndex + 1)) {
			return
		}

		switch {
		case residualLength < thresholdForResidualSort:
			sort.Sort(subslice)
		case keyIndex <= (maxKeyIndex - 2):
			subslice.multikeyRadixSort(tmp, keyIndex+1)
		default:
			subslice.radixSort(tmp, keyIndex+1, 32)
		}
	}
}
// radixSortDescent is radixSort's outsourced descent- and recurse steps.
// Extracted for easier profiling.
radixSortDescent is radixSort's outsourced descent- and recurse steps.
Extracted for easier profiling.
// radixSortDescent is radixSort ' s outsourced descent - and recurse steps . // Extracted for easier profiling .
func (p VersionPtrs) radixSortDescent(tmp []*Version, keyIndex uint8) {
	if keyIndex >= maxKeyIndex {
		return 
	}
	startIdx := 0
	lastValue := p[0].version[keyIndex]
	for i, v := range p {
		value := v.version[keyIndex]
		if lastValue == value { 
			continue
		}
		if i-startIdx < 2 {
			startIdx, lastValue = i, value
			continue
		}
		subslice := p[startIdx:i]
		if subslice.isSorted(uint(keyIndex + 1)) {
			startIdx, lastValue = i, value
			continue
		}
		residualLength := i - startIdx
		startIdx, lastValue = i, value
		switch {
		case residualLength < thresholdForResidualSort:
			sort.Sort(subslice)
		case keyIndex <= (maxKeyIndex - 2):
			subslice.multikeyRadixSort(tmp, keyIndex+1)
		default:
			subslice.radixSort(tmp, keyIndex+1, 32)
		}
	}
	if residualLength := len(p) - startIdx; residualLength > 1 {
		subslice := p[startIdx:]
		if subslice.isSorted(uint(keyIndex + 1)) {
			return
		}
		switch {
		case residualLength < thresholdForResidualSort:
			sort.Sort(subslice)
		case keyIndex <= (maxKeyIndex - 2):
			subslice.multikeyRadixSort(tmp, keyIndex+1)
		default:
			subslice.radixSort(tmp, keyIndex+1, 32)
		}
	}
}
func ( p VersionPtrs ) radixSortDescent ( tmp [ ] * Version , keyIndex uint8 ) { if keyIndex >= maxKeyIndex { return } startIdx := 0 lastValue := p [ 0 ] . version [ keyIndex ] for i , v := range p { value := v . version [ keyIndex ] if lastValue == value { continue } if i - startIdx < 2 { startIdx , lastValue = i , value continue } subslice := p [ startIdx : i ] if subslice . isSorted ( uint ( keyIndex + 1 ) ) { startIdx , lastValue = i , value continue } residualLength := i - startIdx startIdx , lastValue = i , value switch { case residualLength < thresholdForResidualSort : sort . Sort ( subslice ) case keyIndex <= ( maxKeyIndex - 2 ) : subslice . multikeyRadixSort ( tmp , keyIndex + 1 ) default : subslice . radixSort ( tmp , keyIndex + 1 , 32 ) } } if residualLength := len ( p ) - startIdx ; residualLength > 1 { subslice := p [ startIdx : ] if subslice . isSorted ( uint ( keyIndex + 1 ) ) { return } switch { case residualLength < thresholdForResidualSort : sort . Sort ( subslice ) case keyIndex <= ( maxKeyIndex - 2 ) : subslice . multikeyRadixSort ( tmp , keyIndex + 1 ) default : subslice . radixSort ( tmp , keyIndex + 1 , 32 ) } } }
radixSortDescent is radixSort's outsourced descent- and recurse steps.
radixSortDescent is radixSort ' s outsourced descent - and recurse steps .
// Nothing to sort anymore. // The descent. Unlike this, multikeyRadixSort does only one run and hence // is able to read strides from its histogram ("offset[]"). // As classical radix sort cannot (even if optimized to one run for the histogram), // the collection needs to be visited once more here. // Accumulate spans of the same value. // Capture trailer of same values (such as 250.100, 250.0).