@list=("A","B", "C","D" );
print "Original list: @list\n";
# ASCII sort using a subroutine
sub asc_sort{
$a cmp $b; # Sort ascending order
}
@sorted_list=sort asc_sort(@list);
print "Ascii sort: @sorted_list\n";
# Numeric sort using subroutine
sub numeric_sort {
$a <=> $b ;
} # $a and $b are compared numerically
@number_sort=sort numeric_sort 10, 0, 5, 9.5, 10, 1000;
print "Numeric sort: @number_sort.\n";