All pastes #956209 Raw Edit

Stuff

public text v1 · immutable
#956209 ·published 2008-03-25 02:36 UTC
rendered paste body
[20:10] <plataman> I have been asked to Use two loops and an if statement to sort the contents of the array so that the number go from lowest to highest. 
[20:11] <plataman> #!/usr/bin/perl
[20:11] <plataman> @array = (5,3,2,1,4);
[20:11] <plataman> foreach $elem (@array){
[20:11] <plataman> print "$elem";
[20:11] <plataman> }
[20:11] * raizor has joined #perl
[20:13] <aneuryzm> why whats wrong with, sort {$a <=> $b} (5,3,2,1,4); ?
[20:15] <plataman> my teacher asked me to do this and I wasnt quite sure. He wanted use two loops. One loop should progress through the array comparing and swapping adjacent elements (if necessary). The second loop is used to make sure this happens multiple times based on the size of the array. 
[20:37] <aneuryzm> oh
[20:38] <aneuryzm> excuse the delay, was in the other room.. but here
[20:38] <aneuryzm> plataman
[20:38] <aneuryzm> http://www.pastebin.ca/956144
[20:40] <plataman> thanks man
[20:40] <aneuryzm> yup
[21:25] * plataman has left #perl
[21:31] <aneuryzm> oops
[21:32] <aneuryzm> http://www.pastebin.ca/956204
[21:32] <aneuryzm> just noticed that..