<br>How much physical RAM (not the virtual memory, but the physical memory) does your machine have available?  We know the number of elements in your dataset, but how big are the individual elements?  If a sort is never completing, you're probably swapping.<br>
<br>list.sort() is preferrable to sorted(list), if you need to conserve memory.<br><br>A self-sorting datastructure like a B Tree or whatever is rarely faster than using a good sorting algorithm, assuming that you only need to sort the data once per program invocation.  If you're sorting the data in a loop, then yes, a self-sorting datastructure is most likely a much better idea.  I've started a page about python trees and heaps at <a href="http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/">http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/</a> - but again, unless you're sorting in a loop, you're probably better off with a good sorting algorithm, and Python's built-in Timsort is excellent for all-in-RAM sorting.<br>
<br>If you have too much data to sort in RAM all at once, it's best to sort sublists that -do- fit in memory, using something like list_.sort() (that's Timsort by another name in CPython), and then write the sorted sublists to disk for subsequent merging using the merge step of a mergesort.<br>
<br>If you just need something quick-to-code, GNU sort(1) is very highly optimized (for a text-based sort), and will sort datasets that are larger than your physical memory efficiently using an algorithm similar to (not identical) what I described in the previous paragraph.  It's /usr/bin/sort on most Linux systems, and is available for a large number of other operating systems including windows via <a href="http://cygwin.com/">http://cygwin.com/</a> or <a href="https://github.com/bmatzelle/gow/wiki/">https://github.com/bmatzelle/gow/wiki/</a><br>
<br><div class="gmail_quote">On Sun, May 6, 2012 at 8:57 AM, J. Mwebaze <span dir="ltr"><<a href="mailto:jmwebaze@gmail.com" target="_blank">jmwebaze@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have several lists with approx 1172026 entries. I have been trying to sort the records, but have failed.. I tried lists.sort() i also trired sorted python's inbuilt method. This has been running for weeks.<div><br></div>

<div>Any one knows of method that can handle such lists. </div><div><br></div><div>cheers</div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br><div><div><div><br></div>-- <br><font style="color:rgb(0,51,0)" size="1"><b>Mob UG: <a href="tel:%2B256%20%280%29%2070%201735800" value="+256701735800" target="_blank">+256 (0) 70 1735800</a> | NL <a href="tel:%2B31%20%280%29%206%20852%20841%2038" value="+31685284138" target="_blank">+31 (0) 6 852 841 38</a> | Gtalk: jmwebaze |  skype: mwebazej | URL: <a href="http://www.astro.rug.nl/%7Ejmwebaze" target="_blank">www.astro.rug.nl/~jmwebaze</a><br>

<br>/* Life runs on code */</b></font><br><br>
</div></div></div>
</font></span><br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>