Created
May 13, 2011 05:22
-
-
Save joecannatti/970011 to your computer and use it in GitHub Desktop.
naive bubble sort -- perl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@data = (); | |
for($a=0;$a<1000;$a++){ | |
@data = (165, 233,447,497,313,258,394,185,18,164,402,442,409,309,477,55,149,23,315,361,279,248,278,479,299,149,56,229,421,273,56,353,123,285,386,162,60,382,217,396,248,329,438,217,62,1,389,205,68,17,350,183,259,10,459,257,370,394,495,251,108,406,106,433,297,72,473,412,230,401,31,207,6,230,227,110,43,215,60,320,366,403,119,47,424,36,231,429,71,316,154,216,136,73,345,237,409,56,394,461,119,217,37,449,478,64,142,450,178,342,338,214,423,462,433,489,323,444,232,140,276,431,363,334,304,434,74,337,389,255,148,63,166,279,57,58,12,440,309,489,69,92,415,148,472,187,181,302,170,390,65,307,474,135,73,491,431,22,239,428,151,82,227,399,110,458,191,295,40,0,5,479,188,478,72,357,309,254,362,431,119,146,103,197,53,148,93,398,322,405,323,80,439,379,101,54,401,89,6,378,450,326,122,137,469,15,384,190,331,20,94,224,147,57,465,39,482,86,405,81,150,270,72,25,368,0,163,152,53,270,58,360,35,318,336,130,210,371,266,21,278,310,369,265,327,222,392,453,261,273,98,352,251,120,354,453,483,243,326,130,489,125,162,349,172,86,411,481,294,48,229,312,353,332,415,303,317,66,407,445,259,183,236,8,214,105,65,366,36,239,109,492,254,231,286,232,40,19,133,417,164,360,98,468,174,438,50,479,140,381,267,315,391,414,393,166,54,126,98,297,473,207,14,104,342,145,225,189,413,141,363,180,319,120,108,94,302,366,482,491,425,95,98,64,250,288,153,133,87,323,19,133,153,399,120,78,225,215,408,104,138,448,403,237,490,8,359,486,243,415,348,148,27,419,50,61,123,271,153,149,480,384,392,3,124,303,475,29,264,208,402,19,241,487,78,72,494,486,380,246,334,227,364,448,218,258,114,306,12,376,40,192,489,325,268,138,330,31,233,120,99,133,345,463,304,122,468,131,489,466,339,65,425,432,85,62,472,64,368,390,154,493,201,12,150,21,31,323,117,62,48,73,283,270,299,170,259,158,468,55,11,87,210,45,131,247,451,287,205,79,274,237,425,320,43,446,423,83,379,310,384,366,214,475,382,137,147,414,36,383,35,40,480,8,77,430,87,81,92,156); | |
for($r=0;$r<500;$r++){ | |
for my $i (0 .. $#data-1) { | |
if($data[$i] > $data[$i+1]){ | |
$tmp = $data[$i]; | |
$data[$i] = $data[$i+1]; | |
$data[$i+1] = $tmp; | |
} | |
} | |
} | |
} | |
print "@data"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment