Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sort class by attribute

import operator
sorted_x = sorted(x, key=operator.attrgetter('score'))

# In Place:
x.sort(key=operator.attrgetter('score'))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #sort #class #attribute
ADD COMMENT
Topic
Name
9+1 =