#!/usr/bin/env perl use 5.010; use strict; use warnings; my $animals = { gnu => { humps => 0, }, dromedary => { humps => 1, }, camel => { humps => 2, }, }; my @humps; push @humps, $_->{humps} for map { $animals->{$_} } keys %$animals; say "Unsorted humps: @humps"; my @sorted_animals = qw{gnu dromedary camel}; my @sorted_humps; push @sorted_humps, $_->{humps} for map { $animals->{$_} } @sorted_animals; say "Sorted humps: @sorted_humps";