The UNIX sort command can sort a very large file like this:
sort
sort large_file
How is the sort algorithm implemented?
How come it does not cause excessive consumption of memory?
The Algorithmic details of UNIX Sort command says Unix Sort uses an External R-Way merge sorting algorithm. The link goes into more details, but in essence it divides the input up into smaller portions (that fit into memory) and then merges each portion together at the end.
2.1m questions
2.1m answers
60 comments
57.0k users