code: def sort_sweep(sweep, metric, reverse=False):
      """Sorts sweep by any metric (including non scalar metrics)."""
      keys = get_vals(sweep, metric)
      keys = [
          k if np.isscalar(k) else json.dumps(k, sort_keys=True)
          for k in keys
      ]
      keys, sweep = zip(
          *sorted(zip(keys, sweep), key=lambda k: k[0], reverse=reverse)
      )
      return sweep, keys
  
file_path: pycls/pycls/sweep/analysis.py
imports: import json
  from functools import reduce
  from operator import getitem
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: sort_sweep(sweep, metric, reverse) and returns: sweep,  keys