We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a=["a","aa"] a.sort(key=len) print(a)
This returns an error that key is not a defined keyword argument: SyntaxError: Unexpected token TypeError: Cannot read property 'type' of undefined
The text was updated successfully, but these errors were encountered:
This is not supported yet.
#26 is tracking adding the sort method to lists #8 is tracking adding keyword arguments
Here is a workaround:
def cmp(a, b): return len(a) - len(b) a=["ccc", "a","aa"] a = sorted(a, cmp) print(a)
To see it in action, you can paste it here: https://rawgit.com/differentmatt/filbert/master/test/interactive.html
Thanks for the feedback!
Sorry, something went wrong.
I just wanted to make a comment regarding your workaround...
cmp is for comparisons of two items. in this case, a and b.
if cmp returns a negative, that means a is less than b. if it returns zero, they are equal, and if it returns a positive value, greater than
so differentmatt, your code is wrong. here's what it should be:
Good catch, updated comment.
No branches or pull requests
This returns an error that key is not a defined keyword argument:
SyntaxError: Unexpected token
TypeError: Cannot read property 'type' of undefined
The text was updated successfully, but these errors were encountered: