bageler,
I am pretty sure this is easier than it sounds. You have an AoH and want to sort it based off one of the hash values. Try the following code and see if it does what you want:
@list = sort { $a->{level} <=> $b->{level} } @list;
# Print code goes here
Cheers -
L~R
Update: After re-reading your problem I realized the issue is not in the sorting but in the printing, which I conveniently left out. Since a great solution has already been provided below, I will only point to my iterative solution by using a stack.