Penggunaan Tupel Lanjutan dalam Python
## Say we have a list of strings we want to sort by the last letter of the string. strs = ['xc', 'zb', 'yd' ,'wa']
## Write a little function that takes a string, and returns its last letter.
##This will be the key function (takes in 1 value, returns 1 value). def MyFn(s): return s[-1]
##Now pass key=MyFn to sorted() to sort by the last letter: print sorted(strs, key=MyFn)
## ['wa', 'zb', 'xc', 'yd']
Happy Heron