Can we hide sorting inside `whichVersions` and rename the function to `whiteVersionsSorted`? This should reduce the amount of repeated code (see L213 for another copy).