Timothy Johnson wrote:
This does not appear to help, perldoc perlop says:Try using 'cmp' instead of '<=>' in your sort. Then it will sort alphanumerically.
"Binary "cmp" returns -1, 0, or 1 depending on whether the left argument
is stringwise less than, equal to, or greater than the right argument."
Which the 30-Dec-02 is still in the same order stringwise. Depending on your database you may be able to fix this by specifying your query as STARTDATE, SYSTEM, TYPE, *, and then not including the first 3 elements in the print, or you could skip any non /I\d+/ keys in the hash and then print them at the bottom. There should be a way to get sort to do it correctly but this escapes me at the moment...
http://danconia.org
-----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]