Last active
August 29, 2015 14:28
-
-
Save daudahmad/6c15d23f02dd76311792 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a useful sorting function to have, concatenates key and value of a tuple and sorts based on that, useful if keys are not unique | |
def sortFunction(tuple): | |
""" Construct the sort string (does not perform actual sorting) | |
Args: | |
tuple: (rating, MovieName) | |
Returns: | |
sortString: the value to sort with, 'rating MovieName' | |
""" | |
key = unicode('%.3f' % tuple[0]) | |
value = tuple[1] | |
return (key + ' ' + value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment