Oops I replied off list twice. (i wish they would just munge the addresses *grumble**grumble*)
On Wed, Oct 28, 2009 at 11:34 AM, Robert Berman <berma...@cfl.rr.com> wrote: Hi, What I am looking for is a better, faster approach. I think there would be a way to build a dictionary but you can't use the X values as keys since keys must be unique. Why can't you use the X values? Just key to a list. Eg. for the data 0 5 0 2 0 1 2 3 2 1 5 2 5 1 Your dictionary would look like: {0:[5,2,1], 2:[3,1], 5:[2,1]} 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. You can't get around sorting to sort values. 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. Python's sort is really really optimized. 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. -Luke >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor