
adam25bc
Novice
Dec 16, 2011, 9:47 AM
Post #1 of 9
(5882 views)
|
Hello All, I am trying to create a bubble sort as following :
use strict; my @array = (3,2,5,1,4); for (0 .. $#array -1) { for (0 .. $#array -1) { if ($array[$_] > $array[$_+1]) { my $tmp = $array[$_]; $array[$_] = $array[$_+1]; $array[$_+1] = $tmp; } } } print "@array"; but I would like to have this sort shows also ascending sort as well. Also do you know how can I pars numbers to this sort , I mean instead of using 1,2,3,5 I can pass the numbers in command line. Thanks
|