def recursive_sort(data_structure):
<EOL>if not isinstance(data_structure, _primitive_types):<EOL><INDENT>is_meta = isinstance(data_structure, Meta)<EOL>was_dict = isinstance(data_structure, WasDict)<EOL>if not (is_meta or was_dict):<EOL><INDENT>was_dict = isinstance(data_structure, dict)<EOL>if not was_dict:<EOL><INDENT>try:<EOL><INDENT>data_structure = data_structure.__dict__<EOL>was_dict = True<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>try:<EOL><INDENT>data_structure = data_structure.items()<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>tlen = -<NUM_LIT:1><EOL>try:<EOL><INDENT>tlen = len(data_structure)<EOL><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT>if tlen != -<NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>if was_dict:<EOL><INDENT>return tuple(sorted(<EOL>[<EOL>(<EOL>recursive_sort(x[<NUM_LIT:0>]),<EOL>recursive_sort(x[<NUM_LIT:1>]),<EOL>)<EOL>for x in data_structure<EOL>],<EOL>key=TraversalBasedReprCompare<EOL>))<EOL><DEDENT>elif is_meta:<EOL><INDENT>return data_structure[<NUM_LIT:0>:-<NUM_LIT:1>] + [<EOL>recursive_sort(<EOL>data_structure[-<NUM_LIT:1>]<EOL>)<EOL>]<EOL><DEDENT>else:<EOL><INDENT>return tuple(sorted(<EOL>[recursive_sort(<EOL>x,<EOL>) for x in data_structure],<EOL>key=TraversalBasedReprCompare,<EOL>))<EOL><DEDENT><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>return data_structure<EOL>
Sort a recursive data_structure.

    :param   data_structure: The structure to convert.

    data_structure must be already sortable or you must use freeze() or dump().
    The function will work with many kinds of input. Dictionaries will be
    converted to lists of tuples.

    >>> _py2_to_py3(vformat(recursive_sort(dump(
    ...     [3, 1, {'c' : 'c', 'a' : 'b', 'b' : 'a'}]
    ... ))))
    (["<class 'dict'>",
      (('a',
        'b'),
       ('b',
        'a'),
       ('c',
        'c'))],
     1,
     3)
    >>> recursive_sort([3, 1, {'c' : 'c', 'a' : 'b', 'b' : 'a'}])
    ((('a', 'b'), ('b', 'a'), ('c', 'c')), 1, 3)
    >>> recursive_sort(_TestClass())
    (('a', 'huhu'),)