def sorted_fields(fields):
 recursed = [dict(field, fields=sorted_fields(field['fields'])) for field in fields]
 return sorted(recursed, key=(lambda field: field['id']))

def sorted_fields ( fields ) : recursed = [ dict ( field , fields = sorted_fields ( field [ 'fields' ] ) ) for field in fields ] return sorted ( recursed , key = ( lambda field : field [ 'id' ] ) )
recursively sort field lists to ease comparison .