def get_order_preserving_anonymizer(self):
    # Look only at translations we generated, ignoring the ones passed in to our ctor.
    generated_translations = dict(self._translations)
    for k in self._word_map.keys():
      del generated_translations[k]
    for k in self._keep:
      del generated_translations[k]

    # Reassign keys to values so that dictionary order is preserved.
    sorted_keys = sorted(generated_translations.keys())
    sorted_values = sorted(generated_translations.values())
    ordered_translations = dict(zip(sorted_keys, sorted_values))

    # Add the preset translations back in.
    for k, v in self._word_map.items():
      ordered_translations[k] = v

    # This anonymizer should only be used on the exact same objects the capture was run on, and
    # it already contains translations for all those, so it needs no wordlist.
    return Anonymizer([], ordered_translations, self._keep, self._strict)
Returns an Anonymizer that preserves dictionary order.
dataset/ETHPy150Open pantsbuild/pants/src/python/pants/backend/jvm/tasks/jvm_compile/anonymizer.py/TranslationCapturer.get_order_preserving_anonymizer