nodes: 0, module; 1, function_definition; 2, function_name:sort_list; 3, parameters; 4, block; 5, identifier:items; 6, expression_statement; 7, comment:# Track by number of words.; 8, expression_statement; 9, function_definition; 10, comment:# Loop through each item.; 11, for_statement; 12, comment:# Sort them.; 13, expression_statement; 14, for_statement; 15, return_statement; 16, comment:"""Sort a simple list by number of words and length."""; 17, assignment; 18, function_name:by_length; 19, parameters; 20, block; 21, identifier:item; 22, identifier:items; 23, comment:# Count the words.; 24, block; 25, assignment; 26, identifier:count; 27, call; 28, block; 29, identifier:output; 30, identifier:track; 31, dictionary; 32, identifier:word1; 33, identifier:word2; 34, return_statement; 35, expression_statement; 36, if_statement; 37, expression_statement; 38, identifier:output; 39, list; 40, identifier:sorted; 41, argument_list; 42, expression_statement; 43, expression_statement; 44, binary_operator:len(word2) - len(word1); 45, assignment; 46, comparison_operator:cword not in track; 47, block; 48, call; 49, call; 50, keyword_argument; 51, assignment; 52, call; 53, call; 54, call; 55, identifier:cword; 56, call; 57, identifier:cword; 58, identifier:track; 59, expression_statement; 60, attribute; 61, argument_list; 62, attribute; 63, argument_list; 64, identifier:reverse; 65, True; 66, identifier:sort; 67, call; 68, attribute; 69, argument_list; 70, identifier:len; 71, argument_list; 72, identifier:len; 73, argument_list; 74, attribute; 75, argument_list; 76, assignment; 77, subscript; 78, identifier:append; 79, identifier:item; 80, identifier:track; 81, identifier:keys; 82, identifier:sorted; 83, argument_list; 84, identifier:output; 85, identifier:extend; 86, identifier:sort; 87, identifier:word2; 88, identifier:word1; 89, identifier:utils; 90, identifier:word_count; 91, identifier:item; 92, keyword_argument; 93, subscript; 94, list; 95, identifier:track; 96, identifier:cword; 97, subscript; 98, keyword_argument; 99, keyword_argument; 100, identifier:all; 101, True; 102, identifier:track; 103, identifier:cword; 104, identifier:track; 105, identifier:count; 106, identifier:key; 107, identifier:len; 108, identifier:reverse; 109, True
code: def sort_list(items):
      """Sort a simple list by number of words and length."""
  
      # Track by number of words.
      track = {}
  
      def by_length(word1, word2):
          return len(word2) - len(word1)
  
      # Loop through each item.
      for item in items:
          # Count the words.
          cword = utils.word_count(item, all=True)
          if cword not in track:
              track[cword] = []
          track[cword].append(item)
  
      # Sort them.
      output = []
      for count in sorted(track.keys(), reverse=True):
          sort = sorted(track[count], key=len, reverse=True)
          output.extend(sort)
  
      return output