In Python, I am trying to sort by date with lambda. I can't understand my error message. The message is:
<lambda>() takes exactly 1 argument (2 given)
The line I have is
a = sorted(a, lambda x: x.modified, reverse=True)
In Python, I am trying to sort by date with lambda. I can't understand my error message. The message is:
<lambda>() takes exactly 1 argument (2 given)
The line I have is
a = sorted(a, lambda x: x.modified, reverse=True)
Use
On Python 2.x, the
sorted
function takes its arguments in this order:so without the
key=
, the function you pass in will be considered acmp
function which takes 2 arguments.