[Maya] getting the order of nodes in the scene?

Is there a way to retrieve the order of nodes in a Maya scene?

Basically, I want to display a list of nodes in a custom UI in the same order they are listed in Outliner.

For example, say I want the list of cameras in the scene in the same order they are listed in Outliner.
In a default file it is:
persp, top, front, side.

cmds.ls(typ=‘transform’) returns:
// Result: [u’front’, u’persp’, u’side’, u’top’] //
… sorted alphabetically.

cmds.ls() returns everything, but the cameras do seem to be sorted by order…
// Result: […, u’persp’, u’perspShape’, u’top’, u’topShape’, u’front’, u’frontShape’, u’side’, u’sideShape’, …] //

Maybe an itemFilter will help…

Edit: itemFilter doesn’t quite do it, it seems to return things in the order they were created, rather than alphabetically.

Edit2: the “dag” flag for the ls command appears to be exactly what I needed!

If it ever becomes necessary you can also use the reorder command to change the outliner order of nodes.

OTOH, If you ever meet a tools dev who treat the order of stuff in the outliner as significant: kill them and dump the body in front of Autodesk headquarters as a lesson to others.