External sort implementation