code: def validate_sort(sort):
      if sort is None:
          return []
      elif isinstance(sort, str):
          sort = [sort]
  
      if isinstance(sort, list):
          if len(sort) > 0 and not isinstance(sort[0], list):
              sort = [sort]
          ret = []
          for col, s in sort:
              if isinstance(s, Sort):
                  s = s.value
              elif not isinstance(s, str) or s not in Sort.options():
                  raise PerspectiveError(
                      "Unrecognized sort direction: %s", s
                  )
              ret.append([col, s])
          return ret
      else:
          raise PerspectiveError(
              "Cannot parse sort type: %s", str(type(sort))
          )
  
file_path: perspective/python/perspective/perspective/viewer/validate.py
imports: from datetime import datetime
  from ..core import ALL_FILTERS, Aggregate, Plugin, Sort
  from ..core.exception import PerspectiveError
label_desc: Use image node_id 7 for calling a global function with example usage: validate_sort(sort) and returns: list, ret