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 |
got it
found the solution...
list.sort(lambda x, y: cmp(x.getPosition()[1], y.getPosition()[1]) does the job! thankz anyway :) |
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]) |
All times are GMT -7. The time now is 12:40 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC