0

What would be the pragmatic way to create a custom order_by or sort function in python/Django, I'm not sure if you could just override the order by function. Ideally it would sort the passed on object/items according to an algorithm?

iamjoanel
  • 25
  • 5
  • 2
    Could you be more specific as to your needs? An `order_by` is pretty flexible. – Henrik Andersson Jul 18 '13 at 07:21
  • 1
    This seems similar... http://stackoverflow.com/questions/7619554/django-custom-order-by – Charlie Jul 18 '13 at 09:29
  • i was kind of thinking that I'd sort the queryset by a custom method based on a specific sorting algorithm. like a bubble sort or something similar? – iamjoanel Jul 18 '13 at 16:38
  • You can't, `order_by` is just an interface for SQL ordering. You should convert queryset to list and sort that list in Python (it will be very slow and resource-consuming on big datasets though). – ilvar Jul 18 '13 at 17:42

0 Answers0