code: func (sorter *TimSorter) nextRun() int {
  	runBase := sorter.runEnd(0)
  	assert2(runBase < sorter.to, fmt.Sprintf("runBase=%v to=%v", runBase, sorter.to))
  	if runBase == sorter.to-1 {
  		return 1
  	}
  	o := runBase + 2
  	if sorter.Less(runBase+1, runBase) {
  		// run must be strictly descending
  		for o < sorter.to && sorter.Less(o, o-1) {
  			o++
  		}
  		sorter.reverse(runBase, o)
  	} else {
  		// run must be non-descending
  		for o < sorter.to && !sorter.Less(o, o-1) {
  			o++
  		}
  	}
  	runHi := runBase + sorter.minRun
  	if sorter.to < runHi {
  		runHi = sorter.to
  	}
  	if o > runHi {
  		runHi = o
  	}
  	sorter.binarySort(runBase, runHi, o)
  	for i := runBase; i < runHi-1; i++ {
  		assert(!sorter.Less(i+1, i))
  	}
  	return runHi - runBase
  }
docs: // Compute the length of the next run, make the run sorted and return its length