On Mon, Dec 7, 2009 at 10:29 PM, <trapd...@trapd00r.se> wrote: > I'm fairly new to perl but loving it. I've run into some trouble though... > Trying to sort a hash by it's key value, which is not a problem by itself; > > foreach(my $key (sort keys %channels)) { > print $key; > } > > What I've been struggling with for the last hour or so is how I could sort > the hash by it's key value and print out both the keys (sorted) and values > (not sorted). My last solution somewhat became a fork bomb and my computer > died. :) >
Does this code do what you want? foreach(my $key (sort keys %channels)) { print $key, ' => ', $keys{$key}; } -- Robert Wohlfarth