Order in set is getting wierd

I have a list of dicts like this: a = [{‘key1’:val, ‘key2’:val, ‘key3’:val},{‘key1’:val, ‘key2’:val, ‘key3′:val}] And I’m trying to get a keys from values to one list like this: a = [‘key1’, ‘key2’, ‘key3’] With this code key_list = set().union(*(b.keys() for b in a)) key_list = list(key_list) >>> [‘key2’, ‘key1’, ‘key3’] Which works, but the…

Details