code: def _getSortedAxisLabels(
      axes: list[Union[AxisDescriptor, DiscreteAxisDescriptor]],
  ) -> Dict[str, list[AxisLabelDescriptor]]:
      """Returns axis labels sorted by their ordering, with unordered ones appended as
      they are listed."""
  
      # First, get the axis labels with explicit ordering...
      sortedAxes = sorted(
          (axis for axis in axes if axis.axisOrdering is not None),
          key=lambda a: a.axisOrdering,
      )
      sortedLabels: Dict[str, list[AxisLabelDescriptor]] = {
          axis.name: axis.axisLabels for axis in sortedAxes
      }
  
      # ... then append the others in the order they appear.
      # NOTE: This relies on Python 3.7+ dict's preserved insertion order.
      for axis in axes:
          if axis.axisOrdering is None:
              sortedLabels[axis.name] = axis.axisLabels
  
      return sortedLabels
  
file_path: catboost/contrib/python/fonttools/fontTools/designspaceLib/statNames.py
imports: from __future__ import annotations
  from dataclasses import dataclass
  from typing import Dict, Optional, Tuple, Union
  import logging
  from fontTools.designspaceLib import AxisDescriptor, AxisLabelDescriptor, DesignSpaceDocument, DesignSpaceDocumentError, DiscreteAxisDescriptor, SimpleLocationDict, SourceDescriptor
label_desc: Use image node_id 2 for calling a global function with example usage: _getSortedAxisLabels(axes) and returns: sortedLabels