code: def order_dict_by(dict_, key_order):
      r
      dict_keys = set(dict_.keys())
      other_keys = dict_keys - set(key_order)
      key_order = it.chain(key_order, other_keys)
      sorted_dict = OrderedDict(
          (key, dict_[key]) for key in key_order if key in dict_keys
      )
      return sorted_dict
docs: r"""
      Reorders items in a dictionary according to a custom key order
  
      Args:
          dict_ (dict_):  a dictionary
          key_order (list): custom key order
  
      Returns:
          OrderedDict: sorted_dict
  
      CommandLine:
          python -m utool.util_dict --exec-order_dict_by
  
      Example:
          >>> # ENABLE_DOCTEST
          >>> from utool.util_dict import *  # NOQA
          >>> import utool as ut
          >>> dict_ = {1: 1, 2: 2, 3: 3, 4: 4}
          >>> key_order = [4, 2, 3, 1]
          >>> sorted_dict = order_dict_by(dict_, key_order)
          >>> result = ('sorted_dict = %s' % (ut.repr4(sorted_dict, nl=False),))
          >>> print(result)
          >>> assert result == 'sorted_dict = {4: 4, 2: 2, 3: 3, 1: 1}'