All,

I have a two-dimension hash which I use to print out information I
retrieved from a DB. I am using a unique identifier as the key to avoid
duplicates. However, I need to sort the entire hash by date, which is a
key on the second level of the hash. How can I sort this? Example:

### CODE

foreach my $key (keys %results) {
        $total_built++;
        print <<EOM;
                <tr>
                        <td class="Regular" width="20%">
                                $results{$key}{'SERIAL'}
                        </td>
                        <td class="Regular" width="20%">
                                $results{$key}{'DATE'}
                        </td>
                        <td class="Regular" width="20%">
                                $results{$key}{'TA'}
                        </td>
                        <td class="Regular" width="20%">
                                $results{$key}{'MODEL'}
                        </td>
                        <td class="Regular" width="20%">
                                $results{$key}{'WIP'}
                        </td>
                </tr>
EOM
}

### OUTPUT

P0174751  2006-03-07 11:24:40.550  TA-F10-072343  RTLO-18918B  320518  
P0174948  2006-03-07 10:20:14.417  TA-D60-048793  FRO-16210C  322604  

What I want is the records to appear on chronological order. I
originally implemented this with a simple array and the actual SQL did
the sorting for me but I needed to get rid of the duplicates and the
only means I could find was by copying to a hash, using the unique ID as
key to overwrite any duplicates on the resulting hash. But now I lost
the original SQL sorting after the copy. Please advise.

Regards,

Javier Moreno
-------------

Eaton | Truck Components
Systems Engineer - Transmissions

"When you have eliminated all which is impossible, then whatever
remains, however improbable, must be the truth" - Sherlock Holmes

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to