Sorting a list of bodies by x-coordinate
Asked by
Christopher Stanbridge
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?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jan Stránský
- Solved:
- Last query:
- Last reply:
To post a message you must log in.