Sorting algorithms/Insertion sort: Difference between revisions

→‎{{header|Perl}}: Rather not use a statement label if I can help it
(Add javascript example)
(→‎{{header|Perl}}: Rather not use a statement label if I can help it)
Line 839:
<lang perl>
sub insertion_sort {
my @a = @_;
ITEM: for my $i (@_0 .. $#a) {
for my $ij (0 .. $#ai - 1) {
if ($_a[$i] < $a[$ij]) {
my $k = splice @a, $i, 0, $_1;
nextsplice ITEM@a, $j, 0, $k;
last;
}
}
push @a, $_;
}
@a;
}
 
 
my @a = (4, 65, 2, -31, 0, 99, 83, 782, 1);
Anonymous user