TypeError: sort() takes no keyword arguments.
It works in python 2.4,What can be the alternative in python 2.3
Thanks ,
Gaurav
You could try:
>>> a.sort()
>>> a = a[::-1]
a.reverse()
a.sort()
a.reverse()
gives the same result. If you don't care about the order of equal items
a.sort()
a.reverse()
will do.
Peter
You could, but you should also be aware that there is a subtle difference.
The 'reverse' keyword argument gives a stable reverse sort, sorting and
then reversing something is not stable. e.g.
>>> data = [(1, 'zzz'), (1, 'abc'), (2, 'def'), (1, 'pqr'), (2, 'jkl')]
>>> a = data[:]
>>> a.sort(lambda p,q: cmp(p[0],q[0]), reverse=True)
>>> a
[(2, 'def'), (2, 'jkl'), (1, 'zzz'), (1, 'abc'), (1, 'pqr')]
>>> a = data[:]
>>> a.sort(lambda p,q: cmp(p[0],q[0]))
>>> a[::-1]
[(2, 'jkl'), (2, 'def'), (1, 'pqr'), (1, 'abc'), (1, 'zzz')]
--
Duncan Booth http://kupuguy.blogspot.com