Thursday, October 20, 2022

Sorting array of numbers in perl

 

@numbers = (13, 9, 22, 27, 1, 3, -4, 10);
print "Original: @numbers\n\n";

@sorted_numbers = sort { $a <=> $b } @numbers;

print "After sorting: @sorted_numbers";

No comments:

Post a Comment