teggy
teggy

Reputation: 6315

sqlalchemy natural sorting

Currently, i am querying with this code: meta.Session.query(Label).order_by(Label.name).all() and it returns me objects sorted by Label.name in this manner ['1','7','1a','5c']. Is there a way i can have the objects returned in the order with their Label.name sorted like this ['1','1a','5c','7']

Thanks!

Upvotes: 1

Views: 1980

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318488

Sorting is done by the database. If you database doesn't support natural sorting your are out of luck and have to sort your rows manually after retrieving them via sqlalchemy.

Upvotes: 2

Related Questions