Ronald Yacketta wrote:

> 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};
>                 }
> 
> }
> 

i don't know what particular order you want but have you try:

#!/usr/bin/perl -w
use strict;

my @array = qw(
        I1=541
        I2=160
        I4=40
        I3=32
        STATDATE=30-DEC-02
        I14=3
        I15=3
        SYSTEM=wb0300ux124
        DATATYPE=OrderSubmit);

print "$_\n" for(sort {
                        my ($f1) = $a =~ /^I(\d+)/;
                        my ($f2) = $b =~ /^I(\d+)/;

                       return $f1 <=> $f2 if($f1  && $f2);
                       return 1           if($f1  && !$f2);
                       return -1          if(!$f1 && $f2);
                       return $a cmp $b;

                } @array);

__END__

prints:

DATATYPE=OrderSubmit
STATDATE=30-DEC-02
SYSTEM=wb0300ux124
I1=541
I2=160
I3=32
I4=40
I14=3
I15=3

know what the above does because depends on your data, it might not work. it 
should give you a place to start.

david

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

Reply via email to