Sorted dynamic inventory

Hi community,
if I use datagerry as a source for a dynamic ansible inventory via the provided script, is there a way to get it as a sorted list already from datagerry? For example, if I need the first server, it is always a “| sort | first” in the playbook. Is there another way to achieve this?
Best regards
Steffen