in reply to Sorting data returned from DBI ...

You shouldn't need to re-sort after the fact. Check your SQL documentation on ORDER BY. The ORDER BY clause allows you to specify multiple search criteria, in order of significance. You're already using ORDER BY, you may as well use it to its full potential. You might reconstruct your ORDER BY clause like this:

.... ORDER BY city, last, first

Check out this online resource for details on ORDER BY.


Dave

Replies are listed 'Best First'.
Re^2: Sorting data returned from DBI ...
by chinamox (Scribe) on Dec 10, 2006 at 07:09 UTC

    Thank for the link and uber fast response! That was what exactly what I needed. I was going through the DBI documentation this morning but it had not occurred to me that you could use ORDER BY like that.

    -mox

      In general, if you can push some task off onto the database (out of Perl's hands) you're better off. This is only a general rule of thumb, but it seems to hold in most cases. When in doubt, let the database do the work.

      In this case, you were already sorting once in the database, and then contemplating sorting again within Perl. That would mean performing two O(n log n) exercises instead of one.


      Dave