code: def sort_list(items):
      
  
      # 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
docs: Sort a simple list by number of words and length.