Open danieltanfh95 opened 10 years ago
This is not supported yet.
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!
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:
def cmp(a, b): return len(a) - len(b)
a=["ccc", "a","aa"]
a = sorted(a, cmp)
print(a)
Good catch, updated comment.
This returns an error that key is not a defined keyword argument: SyntaxError: Unexpected token TypeError: Cannot read property 'type' of undefined