nodes: 0, module; 1, function_definition; 2, function_name:_sort_schema; 3, parameters; 4, block; 5, identifier:schema; 6, expression_statement; 7, if_statement; 8, comment:"""Recursively sorts a JSON schema by dict key."""; 9, call; 10, block; 11, elif_clause; 12, else_clause; 13, identifier:isinstance; 14, argument_list; 15, for_statement; 16, call; 17, block; 18, block; 19, identifier:schema; 20, identifier:dict; 21, pattern_list; 22, call; 23, block; 24, identifier:isinstance; 25, argument_list; 26, for_statement; 27, expression_statement; 28, identifier:k; 29, identifier:v; 30, identifier:sorted; 31, argument_list; 32, if_statement; 33, identifier:schema; 34, identifier:list; 35, identifier:v; 36, identifier:schema; 37, block; 38, yield; 39, call; 40, call; 41, block; 42, elif_clause; 43, else_clause; 44, if_statement; 45, identifier:d; 46, attribute; 47, argument_list; 48, identifier:isinstance; 49, argument_list; 50, expression_statement; 51, call; 52, block; 53, block; 54, call; 55, block; 56, elif_clause; 57, else_clause; 58, identifier:schema; 59, identifier:items; 60, identifier:v; 61, identifier:dict; 62, yield; 63, identifier:isinstance; 64, argument_list; 65, expression_statement; 66, expression_statement; 67, identifier:isinstance; 68, argument_list; 69, expression_statement; 70, call; 71, block; 72, block; 73, expression_list; 74, identifier:v; 75, identifier:list; 76, yield; 77, yield; 78, identifier:v; 79, identifier:dict; 80, yield; 81, identifier:isinstance; 82, argument_list; 83, expression_statement; 84, expression_statement; 85, identifier:k; 86, call; 87, expression_list; 88, expression_list; 89, call; 90, identifier:v; 91, identifier:list; 92, yield; 93, yield; 94, identifier:OrderedDict; 95, argument_list; 96, identifier:k; 97, call; 98, identifier:k; 99, identifier:v; 100, identifier:OrderedDict; 101, argument_list; 102, call; 103, identifier:v; 104, call; 105, identifier:list; 106, argument_list; 107, call; 108, identifier:list; 109, argument_list; 110, identifier:_sort_schema; 111, argument_list; 112, call; 113, identifier:_sort_schema; 114, argument_list; 115, call; 116, identifier:v; 117, identifier:_sort_schema; 118, argument_list; 119, identifier:v; 120, identifier:_sort_schema; 121, argument_list; 122, identifier:v; 123, identifier:v
code: def _sort_schema(schema):
      """Recursively sorts a JSON schema by dict key."""
  
      if isinstance(schema, dict):
          for k, v in sorted(schema.items()):
              if isinstance(v, dict):
                  yield k, OrderedDict(_sort_schema(v))
              elif isinstance(v, list):
                  yield k, list(_sort_schema(v))
              else:
                  yield k, v
      elif isinstance(schema, list):
          for v in schema:
              if isinstance(v, dict):
                  yield OrderedDict(_sort_schema(v))
              elif isinstance(v, list):
                  yield list(_sort_schema(v))
              else:
                  yield v
      else:
          yield d