Builds a sorted portion one element at a time.