in reply to How to sort a AoH reference

That gives me:
Useless use of sort in scalar context at ./testsort.pl line 22.
Changing the "my $sorted" to "my @sorted" (and the like changes below in the foreach loop) gives me sorted results.

(and I assume the code is not cut-and-pasted, because "[$a->{menuname}" would cause a compile error)