if obj is an instance of Field, append to a list a tuple with 2 elements: field_name, and poped value under the field_name key of the attrs dictionary, substitute the resulting list for fields. sort fields elements with key being a lambda function with argument x and return value creation_counter filed of first element of x.
fields . sort ( key = lambda x : x [ 1 ] . creation_counter )