def direction(col_spec):
  """
  Gets direction for column expression (1 for ascending - 1 for descending).
  """
  if isinstance(col_spec, int):
    return 1 if col_spec >= 0 else -1
  else:
    assert col_spec
    return 1 if col_spec[0] != "-" else -1