nodes: 0, module; 1, function_definition; 2, function_name:_sort_topk_votes; 3, parameters; 4, block; 5, identifier:x; 6, identifier:k; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""
      Sort a dictionary of classes and corresponding vote totals according to the
      votes, then truncate to the highest 'k' classes.
      """; 11, assignment; 12, list_comprehension; 13, identifier:y; 14, subscript; 15, dictionary; 16, for_in_clause; 17, call; 18, slice; 19, pair; 20, pair; 21, identifier:i; 22, identifier:y; 23, identifier:sorted; 24, argument_list; 25, identifier:k; 26, string; 27, subscript; 28, string; 29, subscript; 30, call; 31, keyword_argument; 32, keyword_argument; 33, string_content:class; 34, identifier:i; 35, integer:0; 36, string_content:votes; 37, identifier:i; 38, integer:1; 39, attribute; 40, argument_list; 41, identifier:key; 42, lambda; 43, identifier:reverse; 44, True; 45, identifier:x; 46, identifier:items; 47, lambda_parameters; 48, subscript; 49, identifier:x; 50, identifier:x; 51, integer:1
code: def _sort_topk_votes(x, k):
      """
      Sort a dictionary of classes and corresponding vote totals according to the
      votes, then truncate to the highest 'k' classes.
      """
      y = sorted(x.items(), key=lambda x: x[1], reverse=True)[:k]
      return [{'class': i[0], 'votes': i[1]} for i in y]