code: def _sort_exp(
      experiments: Iterable["ExpRange"],
      sort_path: str,
      sort_name: str,
      typ: str,
      reverse: bool,
  ) -> List["ExpRange"]:
      from funcy import first
  
      def _sort(exp_range: "ExpRange"):
          exp = first(exp_range.revs)
          if not exp:
              return True
          data = (
              exp.data.dumpd()
              .get(typ, {})
              .get(sort_path, {})
              .get("data", {})
          )
          val = flatten(data).get(sort_name)
          return val is None, val
  
      return sorted(experiments, key=_sort, reverse=reverse)
  
imports: from collections import Counter, defaultdict
  from datetime import date, datetime
  from typing import TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Literal, Mapping, NamedTuple, Optional, Set, Tuple, Union
  from dvc.exceptions import InvalidArgumentError
  from dvc.log import logger
  from dvc.scm import Git
  from dvc.ui import ui
  from dvc.utils.flatten import flatten
  from .collect import collect
label_desc: Use image node_id 5 for calling a global function with example usage: _sort_exp(experiments, sort_path, sort_name, typ, reverse) and returns: sorted, unknown,  val, True