Reputation: 476
So far:
def sort_by(column):
for order in sorted(orders, key=lambda order: order.column):
...
list('ratio')
Clearly both ratio
and 'ratio'
are illegal arguments here. I think Django and most other python web frameworks do something like this internally. Is there a pattern for this?
Upvotes: 0
Views: 383
Reputation: 64002
def arrange_list(column):
for order in sorted(orders, key=lambda order: order.__dict__[column]):
...
should do the trick.
Upvotes: 1