code: def sort_by_name(names):
      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)