Python implementation of external sort for sorting large text files