Oops I replied off list twice. <font size="1">(i wish they would just munge the addresses *grumble**grumble*</font>)<br><br>On Wed, Oct 28, 2009 at 11:34 AM, Robert Berman <span dir="ltr"><<a href="mailto:bermanrl@cfl.rr.com" target="_blank">bermanrl@cfl.rr.com</a>></span> wrote:<br>
Hi,<br>What I am looking for is a better, faster approach. I think there would<br><div class="gmail_quote"><div>be a way to build a dictionary but you can't use the X values as keys<br>
since keys must be unique.<br><br><br>Why can't you use the X values? <br>Just key to a list.<br>Eg.<br>for the data <br><div class="im">0 5<br>
0 2<br>
0 1<br>
2 3<br>
2 1<br>
5 2<br>
5 1<br></div>Your dictionary would look like:<br>{0:[5,2,1], 2:[3,1], 5:[2,1]}<br><br>After sorting the sublists you could use itertools to reassemble the original coordinates fairly easily but I still don't think this will be the most optimal way.<br>
<br>You can't get around sorting to sort values.<br>So perhaps you could
give us the exact code you did (on pastebin if it's long, try to cut
out unnecessary cruft before posting) so we can help you make it more
efficient. This should be extremely fast if you're doing the sorting
correctly.<br>
Python's sort is really really optimized.<br><br>Also,
if you can upload a sample input file with a large dataset and indicate
your current running time on the data set and what you're trying to
achieve it will be easier to figure out how to improve your algorithm.<br>
-Luke<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
</blockquote></div><br>