animation nodes sorting object list by XYZ I have a 3x3x3 grid of objects in a collection (intended to be used with non-duplicate objects), I want to sort them by x y and z and have them fed into a loop and animate transformations. I previously did this with index id keys and 3 sort list nodes; one for each axis fed through each other. but the sort list node has since been removed hence why I'm stuck.
I've tried separating the list vectors, running them each through an expression node with sorted(e) but but I'm stuck at how to take X list and sort it by Y, and then Y by Z. any solution or help is greatly appreciated :)
Download my .blend
this is all working except it lacks the control im looking for as to what axis and direction the process begins with

rather than it going from left to right, I want the control to set it so the order is back to front, and then upwards
EDIT: after many hours of tweaking i finally came to a solution using the expressions given to me by gorgious and some extra tweaks:

I used gorgious's method nearly exactly but before feeding the object list into the expression nodes, I created 3 sets of id keys for each axis, input them with object id key nodes, combined them into a vector list and output them into an object transforms output node. the result is full control over direction of animation.
I think you almost got it. I initially started designing loop subprograms but the sorted method and the expression nodes are your friends.
Remember you can chain expression nodes. Add an input of type &quot;Object List&quot;
The 3 expression nodes you should write are like so :

The 3 lines of code:
sorted(objs,key=lambda obj:obj.location[0])
sorted(objs,key=lambda obj:obj.location[1])
sorted(objs,key=lambda obj:obj.location[2])

To visualize it, create a loop subprogram to change the viewport color of the object depending on their order in the new, sorted list.

Add the subprogram at the end of your expression nodes :

Result :

Additionally, as a stand-alone python script :
import bpy

objs = bpy.data.objects; # Replace by relevant objects or collection
for axis in (0, 1, 2):
    objs = sorted(objs, key=lambda obj: obj.location[axis])

objs_len = len(objs)
for i, obj in enumerate(objs):
    fac = i / objs_len
    obj.color = (fac, 1 - fac, 0, 1)

Edit after comment asking for another way to sort the list (right to left, back to front, bottom to top)
You just have to add a slice operator at the end of the 2 first expression nodes to reverse the list : [::-1] See this doc for example (example 2)
So the expressions become :
sorted(objs,key=lambda obj:obj.location[0])[::-1]
sorted(objs,key=lambda obj:obj.location[1])[::-1]
sorted(objs,key=lambda obj:obj.location[2])

Result :