human
Ordering a list of dictionaries in python
assistant
Here is some code to ordering a list of dictionaries `mylist` by elements 'weight' and 'factor'

mylist.sort(key=lambda d: (d['weight'], d['factor']))

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.