code: def order_key_defs(key_def):
      _int = []
      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