Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Sorting Numbers & Text

by dasgar (Curate)
on Jul 12, 2012 at 21:29 UTC ( #981502=note: print w/replies, xml ) Need Help??


in reply to Sorting Numbers & Text

...because I'm using a very large database and don't want to have "not-enough" ram/memory problems.

Since you're using data from a "very large database", it would seem that you're doing some kind of SQL query to retrieve the data from that database. If that's true, would it be possible to add a "sort by" clause to the SQL query to get the database to doing the sorting for you?

Replies are listed 'Best First'.
Re^2: Sorting Numbers & Text
by PriNet (Scribe) on Jul 12, 2012 at 21:50 UTC
    uhhmmm.... you know? if i knew how to do sql, i probably wouldn't have half the problems i get *heh*, but alas, i have a brain block everytime i try to learn it... kinda like learning linux, which also would fix alot of my problems *heh*

    I did try re-inventing the wheel...
    But it kept getting stuck on the corners

      ok, heres one to really twist your coaxial pair...

      if (($OldItem > $NewItem) || (($OldItem == $NewItem) && ($OldItem gt $NewItem))) {}

      the first catches and "sorts" numbers... || ... the second checks to see if "alpha" and sorts texts...
      watcha think? i know there "has" to be a flaw...*heh*

      I did try re-inventing the wheel...
      But it kept getting stuck on the corners

Re^2: Sorting Numbers & Text
by pvaldes (Chaplain) on Jul 13, 2012 at 15:33 UTC

    First of all index your database if not done yet, (or vacuum, analyze and refresh your existent indexes if necessary) and then ask your database to sort your results as indicated by dasgar.

    if i knew how to do sql, i probably wouldn't have half the problems i get...

    Don't panic. Take a look to the sql keyword: "order by"