Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Sorting Numbers & Text

by dasgar (Deacon)
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?


Comment on Re: Sorting Numbers & Text
Re^2: Sorting Numbers & Text
by PriNet (Beadle) 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"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://981502]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-09-18 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (116 votes), past polls