Hello,

I’m curious about your experience with sorting the results of all() 
<http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.all>
 
queries which return a list. It seems to me that there are three ways of 
sorting such result lists:

   1. Use an ORDER BY 
   
<http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.order_by>
 
   in the query and let the database do the sorting.
   2. Use Python’s list.sort() 
   <https://docs.python.org/3/library/stdtypes.html#list.sort> and sort the 
   result list in-place.
   3. Use Python’s sorted() 
   <https://docs.python.org/3/library/functions.html#sorted> function and 
   construct a new and sorted list from the result list.

Is there one preferable over the other, particularly wrt. performance? Is 
sorting on the db side more advantageous than sorting the result list 
later? (For list.sort() vs. sorted() see here 
<https://stackoverflow.com/questions/22442378/what-is-the-difference-between-sortedlist-vs-list-sort-python#22442440>
.)

Thanks!
Jens

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to