def Compare(token1, token2):
    """Compares two tokens and determines their relative order.

    Args:
      token1: The first token to compare.
      token2: The second token to compare.

    Returns:
      A negative integer, zero, or a positive integer as the first token is
      before, equal, or after the second in the token stream.
    """
    if token2.line_number != token1.line_number:
        return token1.line_number - token2.line_number
    else:
        return token1.start_index - token2.start_index