You can download this code by clicking the button below.
This code is now available for download.
Compare two strings lexicographically and return the difference in alphabetical order. If a is less than b, return -1; if a is greater than b, return 1; if they are equal, return 0.
Technology Stack : String comparison
Code Type : Comparison function
Code Difficulty :
def aordiff(a, b):
"""
Compare two strings lexicographically and return the difference in alphabetical order.
"""
return -1 if a < b else 1 if a > b else 0