nodes: 0, module; 1, function_definition; 2, function_name:sort_amounts; 3, parameters; 4, block; 5, identifier:proteins; 6, identifier:sort_index; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""Generic function for sorting peptides and psms. Assumes a higher
      number is better for what is passed at sort_index position in protein."""; 12, assignment; 13, identifier:protein; 14, identifier:proteins; 15, block; 16, list_comprehension; 17, identifier:amounts; 18, dictionary; 19, expression_statement; 20, try_statement; 21, identifier:v; 22, for_in_clause; 23, assignment; 24, block; 25, except_clause; 26, pattern_list; 27, call; 28, identifier:amount_x_for_protein; 29, subscript; 30, expression_statement; 31, identifier:KeyError; 32, block; 33, identifier:k; 34, identifier:v; 35, identifier:sorted; 36, argument_list; 37, identifier:protein; 38, identifier:sort_index; 39, call; 40, expression_statement; 41, call; 42, keyword_argument; 43, attribute; 44, argument_list; 45, assignment; 46, attribute; 47, argument_list; 48, identifier:reverse; 49, True; 50, subscript; 51, identifier:append; 52, identifier:protein; 53, subscript; 54, list; 55, identifier:amounts; 56, identifier:items; 57, identifier:amounts; 58, identifier:amount_x_for_protein; 59, identifier:amounts; 60, identifier:amount_x_for_protein; 61, identifier:protein
code: def sort_amounts(proteins, sort_index):
      """Generic function for sorting peptides and psms. Assumes a higher
      number is better for what is passed at sort_index position in protein."""
      amounts = {}
      for protein in proteins:
          amount_x_for_protein = protein[sort_index]
          try:
              amounts[amount_x_for_protein].append(protein)
          except KeyError:
              amounts[amount_x_for_protein] = [protein]
      return [v for k, v in sorted(amounts.items(), reverse=True)]