in reply to Re^2: Sort in multilevel hash
in thread Sort in multilevel hash

Well, you should use DBI placeholders or quote, otherwise you'll fall for http://bobby-tables.com/

To sort through SQL by shiptofax, its usually a murder of appending

ORDER BY s.shiptofax

And then the results will be sorted, and you won't have to sort your array (you have an array of hashes , stored in a hash, you'd be sorting the array, which you won't have to do if you adjust your query with an ORDER BY clause)

Replies are listed 'Best First'.
Re^4: Sort in multilevel hash
by gueriniere (Initiate) on Jan 09, 2012 at 09:34 UTC
    The problem is to combine ORDER BY and JOIN. Wherever I put it in the query I get syntax error... I am not sure exactly what the join is making so I have not dared to change it into some other query...

      queriniere:

      Try wrapping your SQL query inside another, and sort the outer one, something like:

      select foo, bar, baz from ( select 'a' as foo, 'b' as bar, 'c' as baz from dual union select 'f', 'q', 'z' from dual union select 'x', 'y', 'z' from dual ) order by bar

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

      ORDER BY must be after WHERE (or GROUP BY or HAVING) of the last statement. You effectively have multiple statements thanks to the unions.

      append means add to the end :)