code: def test_as_ordered_dict(self):
      # keyD > keyC > keyE; keyDA > keyDB; Next all other keys alphabetically
      preference_orders = [["keyD", "keyC", "keyE"], ["keyDA", "keyDB"]]
      params = Params(
          {
              "keyC": "valC",
              "keyB": "valB",
              "keyA": "valA",
              "keyE": "valE",
              "keyD": {"keyDB": "valDB", "keyDA": "valDA"},
          }
      )
      ordered_params_dict = params.as_ordered_dict(preference_orders)
      expected_ordered_params_dict = OrderedDict(
          {
              "keyD": {"keyDA": "valDA", "keyDB": "valDB"},
              "keyC": "valC",
              "keyE": "valE",
              "keyA": "valA",
              "keyB": "valB",
          }
      )
      assert json.dumps(ordered_params_dict) == json.dumps(
          expected_ordered_params_dict
      )
  
imports: import json
  import os
  import re
  from collections import OrderedDict
  import pytest
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.params import infer_and_cast, Params, remove_keys_from_params, with_overrides
  from allennlp.common.testing import AllenNlpTestCase
label_desc: Use image node_id 12 for calling the TestParams obj's underlying member method code with example usage: obj.test_as_ordered_dict() without return types