nodes: 0, module; 1, function_definition; 2, function_name:sort_by_name; 3, parameters; 4, block; 5, identifier:names; 6, expression_statement; 7, function_definition; 8, return_statement; 9, comment:"""Sort by last name, uniquely."""; 10, function_name:last_name_key; 11, parameters; 12, block; 13, call; 14, identifier:full_name; 15, expression_statement; 16, if_statement; 17, expression_statement; 18, return_statement; 19, identifier:sorted; 20, argument_list; 21, assignment; 22, comparison_operator:len(parts) == 1; 23, block; 24, assignment; 25, call; 26, call; 27, keyword_argument; 28, identifier:parts; 29, call; 30, call; 31, integer:1; 32, return_statement; 33, identifier:last_first; 34, binary_operator:parts[-1] + ' ' + ' '.join(parts[:-1]); 35, attribute; 36, argument_list; 37, identifier:set; 38, argument_list; 39, identifier:key; 40, identifier:last_name_key; 41, attribute; 42, argument_list; 43, identifier:len; 44, argument_list; 45, call; 46, binary_operator:parts[-1] + ' '; 47, call; 48, identifier:last_first; 49, identifier:upper; 50, identifier:names; 51, identifier:full_name; 52, identifier:split; 53, string; 54, identifier:parts; 55, attribute; 56, argument_list; 57, subscript; 58, string; 59, attribute; 60, argument_list; 61, string_content:; 62, identifier:full_name; 63, identifier:upper; 64, identifier:parts; 65, unary_operator; 66, string_content:; 67, string; 68, identifier:join; 69, subscript; 70, integer:1; 71, string_content:; 72, identifier:parts; 73, slice; 74, unary_operator; 75, integer:1
code: def sort_by_name(names):
      """Sort by last name, uniquely."""
  
      def last_name_key(full_name):
          parts = full_name.split(' ')
          if len(parts) == 1:
              return full_name.upper()
          last_first = parts[-1] + ' ' + ' '.join(parts[:-1])
          return last_first.upper()
  
      return sorted(set(names), key=last_name_key)