You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
439 B
Raku

@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";