Sorting nested groups

We want a script what filters out a specific category with a specific parameter value.
With the package FamilyInstance Location, I read out the point of the filtered family instances.

Those I want to sort by:

  • Level
  • Room
  • Y Point
  • X Point

Until the Y-point it works. Than i get stuck…
What do I wrong?