nodes: 0, module; 1, function_definition; 2, function_name:creation_ordered; 3, parameters; 4, block; 5, identifier:class_to_decorate; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, decorated_definition; 10, expression_statement; 11, comment:# noinspection PyProtectedMember; 12, function_definition; 13, expression_statement; 14, expression_statement; 15, return_statement; 16, comment:"""
          Class decorator that ensures that instances will be ordered after creation order when sorted.
  
          :type class_to_decorate: class
          :rtype: class
      """; 17, assignment; 18, assignment; 19, decorator; 20, function_definition; 21, call; 22, function_name:__lt__; 23, parameters; 24, block; 25, call; 26, assignment; 27, identifier:class_to_decorate; 28, identifier:next_index; 29, call; 30, identifier:__init__orig; 31, attribute; 32, call; 33, function_name:__init__; 34, parameters; 35, block; 36, identifier:setattr; 37, argument_list; 38, identifier:self; 39, identifier:other; 40, return_statement; 41, comment:# pragma: no mutate; 42, identifier:setattr; 43, argument_list; 44, identifier:class_to_decorate; 45, call; 46, attribute; 47, argument_list; 48, identifier:class_to_decorate; 49, identifier:__init__; 50, attribute; 51, argument_list; 52, identifier:self; 53, list_splat_pattern; 54, dictionary_splat_pattern; 55, expression_statement; 56, expression_statement; 57, identifier:class_to_decorate; 58, string; 59, identifier:__init__; 60, comparison_operator:self._index < other._index; 61, identifier:class_to_decorate; 62, string; 63, identifier:__lt__; 64, attribute; 65, argument_list; 66, identifier:functools; 67, identifier:partial; 68, identifier:next; 69, call; 70, identifier:functools; 71, identifier:wraps; 72, identifier:__init__orig; 73, keyword_argument; 74, identifier:args; 75, identifier:kwargs; 76, call; 77, call; 78, string_content:__init__; 79, attribute; 80, attribute; 81, string_content:__lt__; 82, identifier:functools; 83, identifier:total_ordering; 84, identifier:class_to_decorate; 85, attribute; 86, argument_list; 87, identifier:assigned; 88, list; 89, attribute; 90, argument_list; 91, identifier:__init__orig; 92, argument_list; 93, identifier:self; 94, identifier:_index; 95, identifier:other; 96, identifier:_index; 97, identifier:itertools; 98, identifier:count; 99, string; 100, identifier:object; 101, identifier:__setattr__; 102, identifier:self; 103, string; 104, call; 105, identifier:self; 106, list_splat; 107, dictionary_splat; 108, string_content:__doc__; 109, string_content:_index; 110, identifier:next_index; 111, argument_list; 112, identifier:args; 113, identifier:kwargs
code: def creation_ordered(class_to_decorate):
      """
          Class decorator that ensures that instances will be ordered after creation order when sorted.
  
          :type class_to_decorate: class
          :rtype: class
      """
  
      next_index = functools.partial(next, itertools.count())
  
      __init__orig = class_to_decorate.__init__
  
      @functools.wraps(__init__orig, assigned=['__doc__'])
      def __init__(self, *args, **kwargs):
          object.__setattr__(self, '_index', next_index())
          __init__orig(self, *args, **kwargs)
  
      setattr(class_to_decorate, '__init__', __init__)
  
      # noinspection PyProtectedMember
      def __lt__(self, other):
          return self._index < other._index  # pragma: no mutate
  
      setattr(class_to_decorate, '__lt__', __lt__)
  
      class_to_decorate = functools.total_ordering(class_to_decorate)
  
      return class_to_decorate