I was wondering, how is value of item1 and item2 considered?
import functools
lst = [ 2, 1, 3, 6,0, 4, 5]
def compare(item1, item2):
print item1, item2
return (item1) - (item2)
print lst
sorted(lst, key=functools.cmp_to_key(compare))
The output is given below
[2, 1, 3, 6, 0, 4, 5]
1 2
3 1
3 2
6 2
6 3
0 3
0 2
0 1
4 2
4 6
4 3
5 3
5 6
5 4
Out[25]: [0, 1, 2, 3, 4, 5, 6]
I want to know how and on what bases are the values of item1
and item2
are considered?