S
Sameer
Hi,
I wanted to sort hash on keys, So I did the following
#!usr/bin/perl -w
use strict;
my @interval;
my
@midpoint=(45419294,45419807,45420010,45420487,45421043,45421491,45421781,45422084,45422591,45422955,45423008);
my $var;
for ($var=0;$var<@midpoint-1;$var++){
my $x=($midpoint[$var+1]-$midpoint[$var]);
push(@interval,int($x));
}
print "@interval\n";
my $u=0;
my %inv;
my $l;
foreach $l (@interval){
$inv{ ($l) } = ($u);
$u++;
}
my @g=sort (keys %inv);
print "@g\n";
However I am getting results as :
No Sort : 513 203 477 556 448 290 303 507 364 53
Sorted : 203 290 303 364 448 477 507 513 53 556
How can I get sort hash on key so that I get result as
53 203 290 303 364 448 477 507 513 556
Numeric Sort?
Thanks in advance,
Sameer
I wanted to sort hash on keys, So I did the following
#!usr/bin/perl -w
use strict;
my @interval;
my
@midpoint=(45419294,45419807,45420010,45420487,45421043,45421491,45421781,45422084,45422591,45422955,45423008);
my $var;
for ($var=0;$var<@midpoint-1;$var++){
my $x=($midpoint[$var+1]-$midpoint[$var]);
push(@interval,int($x));
}
print "@interval\n";
my $u=0;
my %inv;
my $l;
foreach $l (@interval){
$inv{ ($l) } = ($u);
$u++;
}
my @g=sort (keys %inv);
print "@g\n";
However I am getting results as :
No Sort : 513 203 477 556 448 290 303 507 364 53
Sorted : 203 290 303 364 448 477 507 513 53 556
How can I get sort hash on key so that I get result as
53 203 290 303 364 448 477 507 513 556
Numeric Sort?
Thanks in advance,
Sameer