all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
strings = "here are Some sample strings to be sorted".split()
|
||||
|
||||
def mykey(x):
|
||||
return -len(x), x.upper()
|
||||
|
||||
print sorted(strings, key=mykey)
|
||||
|
|
@ -0,0 +1 @@
|
|||
['strings', 'sample', 'sorted', 'here', 'Some', 'are', 'be', 'to']
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
def mycmp(s1, s2):
|
||||
return cmp(len(s2), len(s1)) or cmp(s1.upper(), s2.upper())
|
||||
|
||||
print sorted(strings, cmp=mycmp)
|
||||
Loading…
Add table
Add a link
Reference in a new issue