external sort implementation