use strict;
use warnings;
test();
sub test
{
my @a = (
["Hobbit", 168, 63],
["Elf", 180, 54],
["Dwarf", 159, 100],
);
my @b = sort byHeight(@a);
my @elmt = ("Human", 176, 70);
my @c = sort byHeight \@elmt, @b;
printDS(\@a);
printDS(\@b);
printDS(\@c);
}
sub byHeight{
$a->[1] <=> $b->[1];
}
sub printDS
{
my $ds = shift;
use Data::Dumper;
print Dumper @$ds;
print "~~~~~~~~~~~~~~~~~~~~~\n";
}
레퍼런스 : Insert into a sorted array키워드 : new element, elmt, binary search
No comments:
Post a Comment