Reverse the Order of a Selection List (Natively)



I use the command “listRelatives -ad” to return all the children a selected object.
The problem is they are in a reverse order.

For instance, if the hierarchy as follows
grandparent (GP)
parent §
 child ©
  grandchild (GC)

It would return as
GC, C, P, GP

rather than
GP, P, C, GC.

I searched over the web and found some hits. Unfortunately, this one uses a custom script (“zooTools”) that needs installation.
I also stumbled upon this native script in this thread
but it does not seem to work and returns the list in the same order.

$selected = `listRelatives -ad `;
for($n=0; $n<size($selected); ++$n) {
print $selected;

Thank you for looking at my problem


if we are talking about MEL:

string $ss[] = `listRelatives -ad`
string $rs[];
int $i = `size($ss)`;
for ($s in $ss) $rs[--$i] = $s;
print $ss
print $rs