I dunno how much this helps, but you can get your query returned sorted by a paricular column in your db by using ORDER BY in your SELECT query.
EG: Say you have a column in your db called date and you wanted your query sorted by the date then you use:
SELECT * FROM dbname ORDER BY date;
thats it. CHeck out the section in the documentation on ORDER BY.
Vikesh.