SyntaxFix
Write A Post
Hire A Developer
Questions
import operator sorted_x = sorted(x, key=operator.attrgetter('score'))
if you want to sort x in-place, you can also:
x.sort(key=operator.attrgetter('score'))