my @nodes = map { $_->[0] } sort { # What goes here?? } map { [ $_->{node_id}, $_->{depth}, $_->{sibling_order} ] } $sth->fetchall_hashref(); #### $a->{depth} <=> $b->{depth} || $a->{sibling_order} <=> $b->{sibling_order}