-4

I want to create a file (size more than 2 GB) of integers (more than 64 bit each) and sort the file efficiently.

hynekcer
  • 14,942
  • 6
  • 61
  • 99
viswas
  • 1,007
  • 1
  • 9
  • 13

1 Answers1

2

1) Divide it to so big files that can be effectively sorted in the memory.
2) Merge those sorted files together into one file.

Details you find in answer [1] which uses module heapq function merge.

Better is to use half of memory then to risk swapping.

I do not see anything wrong on this question. It is only a simple example of principle of the problem.

Community
  • 1
  • 1
hynekcer
  • 14,942
  • 6
  • 61
  • 99
  • 1
    What's wrong with the question is that the OP didn't even bother to search the web or SO for ways to do this, but instead simply posted his or her [homework](http://stackoverflow.com/questions/10074541/sorting-arbitrary-size-integers) for us to solve. – Sven Marnach Apr 09 '12 at 14:27
  • heapq function merge is not merging the files in sorted order. I want that merged file should be sorted. – viswas Apr 10 '12 at 04:35
  • 1
    Did you read anything? "merge -- Merge multiple sorted inputs into a single sorted output." It works for me. – hynekcer Apr 10 '12 at 08:30