code: def reorder_levels(self, dim_order=None, inplace=None,
                         **dim_order_kwargs):
          
          inplace = _check_inplace(inplace)
          dim_order = either_dict_or_kwargs(dim_order, dim_order_kwargs,
                                            'reorder_levels')
          replace_variables = {}
          for dim, order in dim_order.items():
              coord = self._variables[dim]
              index = coord.to_index()
              if not isinstance(index, pd.MultiIndex):
                  raise ValueError("coordinate %r has no MultiIndex" % dim)
              replace_variables[dim] = IndexVariable(coord.dims,
                                                     index.reorder_levels(order))
          variables = self._variables.copy()
          variables.update(replace_variables)
          return self._replace_vars_and_dims(variables, inplace=inplace)
docs: Rearrange index levels using input order.
  
          Parameters
          ----------
          dim_order : optional
              Mapping from names matching dimensions and values given
              by lists representing new level orders. Every given dimension
              must have a multi-index.
          inplace : bool, optional
              If True, modify the dataset in-place. Otherwise, return a new
              DataArray object.
          **dim_order_kwargs: optional
              The keyword arguments form of ``dim_order``.
              One of dim_order or dim_order_kwargs must be provided.
  
          Returns
          -------
          obj : Dataset
              Another dataset, with this dataset's data but replaced
              coordinates.