Swap x and y if x < y.
This fixes the "swapped s and t" issue.