.In a text file there are numbers upto 10 Million randamly...Those numbers should be sorted.How would u do?
Regards
vinni
Printable View
.In a text file there are numbers upto 10 Million randamly...Those numbers should be sorted.How would u do?
Regards
vinni
- read numbers from the file into an array
- sort numbers
- write numbers back to the file
If there are too many numbers to fit in computer memory:
* Divide into portions that do fit
* Sort each portion separately
* Save sorted results to individual files
* Merge the results by reading these sorted files, always picking the smallest number available in any file.
This is called a merge sort