code: def order_key_defs(key_def):
      
      _int = []
      # First make sure all defs only reference one usage
      for kd in key_def:
          if len(kd['use']) > 1:
              for _use in kd['use']:
                  _kd = kd.copy()
                  _kd['use'] = _use
                  _int.append(_kd)
          else:
              _int.append(kd)
  
      _int.sort(key=cmp_to_key(sort_func))
  
      return _int
docs: Sort a set of key definitions. A key definition that defines more then
      one usage type are splitted into as many definitions as the number of
      usage types specified. One key definition per usage type.
  
      :param key_def: A set of key definitions
      :return: The set of definitions as a sorted list