#!/usr/bin/env perl use strict; use warnings; $" = ', '; #nicely format array outputs my @nums = (5, 8, 4, -5, 3.1, 0, 18); #the below uses a "quoted-words" shortcut to avoid the quotes & commas: my @names = qw(hello Hola Paul peter jeffrey hillary Jennifer); print "In descending numeric order, the numbers @nums are:\n"; #your code to sort and print the numbers goes here. my @descending_nums = sort { $b <=> $a } @nums; print "@descending_nums\n\n\n"; print "In ascending alphabetical order (ignoring case), @names are:\n"; #your code to sort and print the names goes here. my @sorted_names = sort { lc $a cmp lc $b } @names; print "@sorted_names\n\n\n"; my %professor_of = ( 'Programming in Perl' => 'Lalli, Paul', 'Computer Science I' => 'Hardwick, Martin', 'Operating Systems' => 'Hollinger, Dave', 'Computer Science II' => 'Stewart, Chuck', 'Programming in Java' => 'Mehta, Alok', 'Computer Organization' => 'Hollinger, Dave', ); #your code to sort and print the professors & classes goes here. my @classes = keys %professor_of; my @sorted_classes = sort { $professor_of{$a} cmp $professor_of{$b} } @classes; for my $class (@sorted_classes){ print "$professor_of{$class} teaches $class\n"; } __END__ notes about the above: 1) I could have combined all three steps into one: for my $class (sort { $professor_of{$a} cmp $professor_of{$b} } keys %professor_of){ print "$class is taught by $professor_of{$class}\n"; } 2) It is common to add an additional "fallback" sort criteria if the main criteria results in a non-determined sort order (as is the case with Dave Hollinger in this example) sub By_Prof_And_Class { if ($professor_of{$a} lt $professor_of{$b}){ return -1; } elsif ($professor_of{$a} gt $professor_of{$b}){ return 1; } else { #professors compare identically, try classes if ($a lt $b){ return -1; } elsif ($a gt $b){ return 1; } else { #classes compare identically too, so it doesn't matter return 0; } } } my @sorted_classes = sort By_Prof_And_Class @classes; 2b) The above could be simplified using the comparison operators and the short-circuit nature of the logical operators: my @sorted classes = sort { $professor_of{$a} cmp $professor_of{$b} or $a cmp $b } @classes;