Front page | perl.beginners |
Postings from July 2012
use sort error
Thread Next
From:
xiyoulaoyuanjia
Date:
July 5, 2012 07:53
Subject:
use sort error
Message ID:
CALBxOKhQnWJkVR0A6xfbrd8CU7Cw2w7XX1HNfW2DVvoUf58Oiw@mail.gmail.com
hi:
i want sort my array .but the result is not right. i did not know why ?
---------------------------------------begin
code----------------------------------------------
perl -e '
@AoH = (
{
rsh => "0.4",
},
{
telnet=> "0.022",
},
{
ssh => "0.3",
},
);
print values($_) for sort my_sort @AoH; sub my_sort {
values($a)<=>values($b)}
'
----------------------------------end
code---------------------------------------------------------
the result is 0.40.0220.3 apparently it did not right!
after i modify my_sort to this
sub my_sort { (values($a))[0]<=>(values($b))[0]}
it can work well ..
anyone can tell me the reason!
tanks!
--
继续上路。。
Thread Next
-
use sort error
by xiyoulaoyuanjia