#1
|
|||
|
|||
sorting by position
Hello
i have a list of nodes, and i would like to sort them according to their height i know python has a list.sort(key = bla) function), but the question is: how do i get the handle to node3d.getPosition()[1] so i can pass it as the key ? or is there another way? thankz dan |
#2
|
|||
|
|||
got it
found the solution...
list.sort(lambda x, y: cmp(x.getPosition()[1], y.getPosition()[1]) does the job! thankz anyway |
#3
|
|||
|
|||
The best method is to use the key parameter instead of the cmp parameter. It is faster and more efficient. Here is some sample code:
Code:
list.sort(key = lambda x: x.getPosition()[1]) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
position tracking with patriot | pgagolf | Vizard | 4 | 04-19-2007 04:42 AM |
Avatar always returns in initial position | pattie | Vizard | 2 | 08-31-2006 08:15 PM |
Get position data in an own little program | Researcher | Precision Position Tracker (PPT) | 2 | 02-01-2006 02:55 AM |
saving the position | poolshark | Vizard | 3 | 09-26-2003 01:57 PM |