Sort and sort generator