Lexicographical Comparison Function

  • Share this:

Code introduction


This function takes two arguments a and b, and returns the lexicographical comparison result between them. If a equals b, it returns 0. If a is greater than b, it returns 1, otherwise it returns -1.


Technology Stack : Built-in comparison operations

Code Type : Comparison function

Code Difficulty : Intermediate


                
                    
def aord_value(a, b):
    if a == b:
        return 0
    return 1 if a > b else -1