← Back to team overview

yade-users team mailing list archive

Re: [Question #254558]: Sorting a list of bodies by x-coordinate

 

Question #254558 on Yade changed:
https://answers.launchpad.net/yade/+question/254558

Description changed to:
At one point in my code, I need to sort a list of bodies from least to greatest x-coordinate. I have attempted to use the sorted() method but am not quite sure what I would use as my "key". I know State.pos[0] stores the x-coordinate, but when I try to use
key=State.pos[0] 
(or, it seems, any variant thereof) I get the following error.
TypeError: 'property' object has no attribute '__getitem__'

What would the correct sort key be here, or if there is none, what
alternate methods would there be to sort particles in order of
x-coordinate?

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.