LN A-go-go <[email protected]> Wrote in message:
>
Please tell your email program to use text when posting here, The
html you used can cause numerous problems. One of them prevents
me from quoting context.
If you can get your data to a list of tuples, then you can sort
that list by something like
sorteddata = sorted (data, key = dist)
Of course you have to write dist. Something like
def dist (tup):
return distance (tup [3], tup [0], tup [1], tup [2]
But of course this depends greatly on the contents of the tuple.
You can also skip the sorting if you just want the lowest value by
doing
mintuple = min (data, key= dist)
Or if you need the 3 closest, you can use heapq.nsmallest
--
DaveA
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor