code: def xyz_order(coordsys, name2xyz=None):
      """Vector of orders for sorting coordsys axes in xyz first order
  
      Parameters
      ----------
      coordsys : ``CoordinateSystem`` instance
      name2xyz : None or mapping, optional
          Object such that ``name2xyz[ax_name]`` returns 'x', or 'y' or 'z' or
          raises a KeyError for a str ``ax_name``.  None means use module default.
  
      Returns
      -------
      xyz_order : list
          Ordering of axes to get xyz first ordering.  See the examples.
  
      Raises
      ------
      AxesError : if there are not all of x, y and z axes
  
      Examples
      --------
      >>> from nipy.core.api import CoordinateSystem
      >>> xyzt_cs = mni_csm(4) # coordsys with t (time) last
      >>> xyzt_cs
      CoordinateSystem(coord_names=('mni-x=L->R', 'mni-y=P->A', 'mni-z=I->S', 't'), name='mni', coord_dtype=float64)
      >>> xyz_order(xyzt_cs)
      [0, 1, 2, 3]
      >>> tzyx_cs = CoordinateSystem(xyzt_cs.coord_names[::-1], 'reversed')
      >>> tzyx_cs
      CoordinateSystem(coord_names=('t', 'mni-z=I->S', 'mni-y=P->A', 'mni-x=L->R'), name='reversed', coord_dtype=float64)
      >>> xyz_order(tzyx_cs)
      [3, 2, 1, 0]
      """
      if name2xyz is None:
          name2xyz = known_names
      names = coordsys.coord_names
      N = len(names)
      axvals = np.zeros(N, dtype=int)
      for i, name in enumerate(names):
          try:
              xyz_char = name2xyz[name]
          except KeyError:
              axvals[i] = N + i
          else:
              axvals[i] = "xyz".index(xyz_char)
      if not set(axvals).issuperset(range(3)):
          raise AxesError(
              "Not all of x, y, z recognized in coordinate map"
          )
      return list(np.argsort(axvals))
  
imports: import numpy
  from nibabel import io_orientation
  from nibabel.affines import from_matvec
  from .coordinate_map import CoordMapMaker
  from .coordinate_system import CoordSysMaker, is_coordsys, is_coordsys_maker
label_desc: Use image node_id 4 for calling a global function with example usage: xyz_order(coordsys, name2xyz) and returns: list