First of all, blender group is not reliable as objects order.
Otherwise, you need a fixed location of objects as a reference for sorting by location.
Given that they are moving around you have to consider only the final position (landed) for sorting.
This goes 2 ways:
you use instancer to copy same object. Here you need to sort the vectors positions (vector list) that give the location of objects (instances), and not the objects
if have a list/group of objects that are different, you have to use id key node (object submenu) to get the initial rot/loc . But first, make sure you set initial transforms (in 3d view, AN panel) for all objects.
This is slightly different and I'll not detail here.
I will detail the first case
For the examples below I use the template Grid Arrange.
- Just use the grid order
This goes naturally if u use the respective template or similar.
- Use a distance to object to sort
In comparison to above, use a vector/ vector distance node to compare each position to an empty (or something else)
- U can further use some expressions
U can do the same by sorting the vector (landed positions) first
as distance to or as direction as shown in the pics with formula:
distance to:
sorted(list, key = lambda item: (item - point).length_squared, reverse = reversed)
direction:
sorted(list, key = lambda item: item.dot(direction), reverse = reversed)
where the inputs are: a vector list, a vector, a boolean
Please note that in all these case I basically sort the vectors, not the objects.
For the other case, you would sort the objects based on the list of (id key ) initial locations.