#!/usr/bin/perl use strict; my @array=(12,6,2,9,15); my ($i,$j,$tmp); for ($i=0; $i<@array; $i++){ for ($j=$i+1;$j<@array;$j++){ if ($array[$j]<$array[$i]){ # '>' reverses the order $tmp = $array[$j]; $array[$j] = $array[$i]; $array[$i] = $tmp; } } } print "array : @array \n";