How to access entities' "natural sort order" in Rules/Buttons/scripts?

Entities can be (re)ordered manually via dragging (i.e. in a Card or List view).
How can such entities’ relative order be determined or set in a Rule/Button/script?

Hi, Matt!
While we’re thinking about the answer, would be glad to hear more details about your use case, really curious about it))))

Example use case:

I have a hierarchical DB of “web pages”. I manually order (by dragging) these to define the desired order of the pages within the website navigation menu.

I want to create a Button that will read this “natural sort order” and generate a bash function to effect this ordering within the website’s WordPress menu (e.g., wp cli commands`).

If you just need to read the sort order, then it is available via a (hidden) field called ‘Rank’ which is a number that determines the ordering (loweest number is highest up the list).

const entityWithExtraFields = await fibery.getEntityById(entity.type, entity.id, ['Rank']);

However the numbers are not simple, single-digit integers. For example, my 5 tasks have the following values:
image

I don’t know how useful this is :thinking:

I think that would work fine - thanks!