sorting - python sort objects by difference in attributes/weights -


is there way sort function in python?

the array holds objects each 1 has weight value.

i'd appreciate javascript sort.

i tried doing cmp run error:

typeerror: comparison function must return int, not float

use python's built in sorted function lambda, , cast result integer.

sorted_list = sorted(unsorted_iterable, lambda x, y: int(x.weight - y.weight))


Comments

Popular posts from this blog

c++ - list<myClass<int> * > sort -

SoapUI on windows 10 - high DPI/4K scaling issue -

java - why am i getting a "cannot resolve method" error on getApplication? -