nodes: 0, module; 1, function_definition; 2, function_name:sort_set; 3, parameters; 4, block; 5, identifier:s; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:"""Return a sorted list of the contents of a set
  
      This is intended to be used to iterate over world state, where you just need keys
      to be in some deterministic order, but the sort order should be obvious from the key.
  
      Non-strings come before strings and then tuples. Tuples compare element-wise as normal.
      But ultimately all comparisons are between values' ``repr``.
  
      This is memoized.
  
      """; 12, not_operator; 13, block; 14, assignment; 15, comparison_operator:s not in _sort_set_memo; 16, block; 17, subscript; 18, call; 19, raise_statement; 20, identifier:s; 21, call; 22, identifier:s; 23, identifier:_sort_set_memo; 24, expression_statement; 25, identifier:_sort_set_memo; 26, identifier:s; 27, identifier:isinstance; 28, argument_list; 29, call; 30, identifier:frozenset; 31, argument_list; 32, assignment; 33, identifier:s; 34, identifier:Set; 35, identifier:TypeError; 36, argument_list; 37, identifier:s; 38, subscript; 39, call; 40, string:"sets only"; 41, identifier:_sort_set_memo; 42, identifier:s; 43, identifier:sorted; 44, argument_list; 45, identifier:s; 46, keyword_argument; 47, identifier:key; 48, identifier:_sort_set_key
code: def sort_set(s):
      """Return a sorted list of the contents of a set
  
      This is intended to be used to iterate over world state, where you just need keys
      to be in some deterministic order, but the sort order should be obvious from the key.
  
      Non-strings come before strings and then tuples. Tuples compare element-wise as normal.
      But ultimately all comparisons are between values' ``repr``.
  
      This is memoized.
  
      """
      if not isinstance(s, Set):
          raise TypeError("sets only")
      s = frozenset(s)
      if s not in _sort_set_memo:
          _sort_set_memo[s] = sorted(s, key=_sort_set_key)
      return _sort_set_memo[s]