nodes: 0, module; 1, function_definition; 2, function_name:order_key_defs; 3, parameters; 4, block; 5, identifier:key_def; 6, expression_statement; 7, expression_statement; 8, comment:# First make sure all defs only reference one usage; 9, for_statement; 10, expression_statement; 11, return_statement; 12, comment:"""
      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
      """; 13, assignment; 14, identifier:kd; 15, identifier:key_def; 16, block; 17, call; 18, identifier:_int; 19, identifier:_int; 20, list; 21, if_statement; 22, attribute; 23, argument_list; 24, comparison_operator:len(kd['use']) > 1; 25, block; 26, else_clause; 27, identifier:_int; 28, identifier:sort; 29, keyword_argument; 30, call; 31, integer:1; 32, for_statement; 33, block; 34, identifier:key; 35, call; 36, identifier:len; 37, argument_list; 38, identifier:_use; 39, subscript; 40, block; 41, expression_statement; 42, identifier:cmp_to_key; 43, argument_list; 44, subscript; 45, identifier:kd; 46, string; 47, expression_statement; 48, expression_statement; 49, expression_statement; 50, call; 51, identifier:sort_func; 52, identifier:kd; 53, string; 54, string_content:use; 55, assignment; 56, assignment; 57, call; 58, attribute; 59, argument_list; 60, string_content:use; 61, identifier:_kd; 62, call; 63, subscript; 64, identifier:_use; 65, attribute; 66, argument_list; 67, identifier:_int; 68, identifier:append; 69, identifier:kd; 70, attribute; 71, argument_list; 72, identifier:_kd; 73, string; 74, identifier:_int; 75, identifier:append; 76, identifier:_kd; 77, identifier:kd; 78, identifier:copy; 79, string_content:use
code: def order_key_defs(key_def):
      """
      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
      """
      _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