code: def _format_dig_points(dig, enforce_order=False):
      """Format the dig points nicely."""
      if enforce_order and dig is not None:
          # reorder points based on type:
          # Fiducials/HPI, EEG, extra (headshape)
          fids_digpoints = []
          hpi_digpoints = []
          eeg_digpoints = []
          extra_digpoints = []
          head_digpoints = []
  
          # use a heap to enforce order on FIDS, EEG, Extra
          for idx, digpoint in enumerate(dig):
              ident = digpoint["ident"]
              kind = digpoint["kind"]
  
              # push onto heap based on 'ident' (for the order) for
              # each of the possible DigPoint 'kind's
              # keep track of 'idx' in case of any clashes in
              # the 'ident' variable, which can occur when
              # user passes in DigMontage + DigMontage
              if kind == FIFF.FIFFV_POINT_CARDINAL:
                  heapq.heappush(fids_digpoints, (ident, idx, digpoint))
              elif kind == FIFF.FIFFV_POINT_HPI:
                  heapq.heappush(hpi_digpoints, (ident, idx, digpoint))
              elif kind == FIFF.FIFFV_POINT_EEG:
                  heapq.heappush(eeg_digpoints, (ident, idx, digpoint))
              elif kind == FIFF.FIFFV_POINT_EXTRA:
                  heapq.heappush(
                      extra_digpoints, (ident, idx, digpoint)
                  )
              elif kind == FIFF.FIFFV_POINT_HEAD:
                  heapq.heappush(head_digpoints, (ident, idx, digpoint))
  
          # now recreate dig based on sorted order
          fids_digpoints.sort(), hpi_digpoints.sort()
          eeg_digpoints.sort()
          extra_digpoints.sort(), head_digpoints.sort()
          new_dig = []
          for idx, d in enumerate(
              fids_digpoints
              + hpi_digpoints
              + extra_digpoints
              + eeg_digpoints
              + head_digpoints
          ):
              new_dig.append(d[-1])
          dig = new_dig
  
      return [DigPoint(d) for d in dig] if dig is not None else dig
  
imports: import heapq
  from collections import Counter
  import numpy
  from ..utils import Bunch, _check_fname, _validate_type, logger, verbose, warn
  from .constants import FIFF, _coord_frame_named
  from .tag import read_tag
  from .tree import dir_tree_find
  from .write import start_and_end_file, write_dig_points
label_desc: Use image node_id 1 for calling a global function with example usage: _format_dig_points(dig, enforce_order) and returns: unknown