WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-26-2008, 03:01 AM
dan12345 dan12345 is offline
Member
 
Join Date: Jan 2008
Posts: 58
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
Reply With Quote
  #2  
Old 03-26-2008, 03:06 AM
dan12345 dan12345 is offline
Member
 
Join Date: Jan 2008
Posts: 58
got it

found the solution...

list.sort(lambda x, y: cmp(x.getPosition()[1], y.getPosition()[1])

does the job!

thankz anyway
Reply With Quote
  #3  
Old 03-26-2008, 11:32 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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])
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -7. The time now is 06:49 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC