Try using 'cmp' instead of '<=>' in your sort.  Then it will sort
alphanumerically.

-----Original Message-----
From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 10, 2003 4:43 PM
To: [EMAIL PROTECTED]
Subject: hash sorting


Can some please help here :)

I have the following


sub dbMonthlySelect() {
        my $query;
        my $result;

        $query = "select * from mbstats_se where
STATDATE=TO_DATE('12/30/02','MM/DD/YY')";
        $result = &doQuery($query,'dbMonthlySelect');

        my $i = $result->fetchrow_hashref;
                for my $key (sort { $i->{$b} <=> $i->{$a} } (keys %$i)) {
                        print "$key = $i->{$key} \n" if defined $i->{$key};
                }

}

and it sorts like this:


I1 = 541
I2 = 160
I4 = 40
I3 = 32
STATDATE = 30-DEC-02
I5 = 9
I6 = 8
I8 = 6
I11 = 5
I7 = 4
I18 = 4
I14 = 3
I15 = 3
I17 = 3
I13 = 3
I21 = 2
I10 = 2
I98 = 1
I20 = 1
I16 = 1
I23 = 1
SYSTEM = wb0300ux124
DATATYPE = OrderSubmit




When it should be like this:
                     I
DATATYPE = OrderSubmit
STATDATE = 30-DEC-02
SYSTEM = wb0300ux124
I1 = 541
I2 = 160
I3 = 32
I4 = 40
I5 = 9
I6 = 8
I7 = 4
I8 = 6
I10 = 2
I11 = 5
I13 = 3
I14 = 3
I15 = 3
I16 = 1
I17 = 3
I18 = 4
I21 = 2
I20 = 1
I23 = 1
I98 = 1

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to