Sequence sorting in secondary storage