It's supposed to look for patch segments in ascending order, from the smallest offset to the largest offset. Patch type/comparison is identical to the one it's being swapped with, so only the offsets need to be swapped.