nodes: 0, module; 1, function_definition; 2, function_name:sort_response; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, identifier:OrderedDict; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, identifier:response; 15, type; 16, comment:"""
      Sort the keys in a JSON-RPC response object.
  
      This has no effect other than making it nicer to read. Useful in Python 3.5 only,
      dictionaries are already sorted in newer Python versions.
  
      Example::
  
          >>> json.dumps(sort_response({'id': 2, 'result': 5, 'jsonrpc': '2.0'}))
          {"jsonrpc": "2.0", "result": 5, "id": 1}
  
      Args:
          response: Deserialized JSON-RPC response.
  
      Returns:
          The same response, sorted in an OrderedDict.
      """; 17, assignment; 18, assignment; 19, assignment; 20, comparison_operator:"error" in response; 21, block; 22, identifier:req; 23, generic_type; 24, identifier:root_order; 25, list; 26, identifier:error_order; 27, list; 28, identifier:req; 29, call; 30, string:"error"; 31, identifier:response; 32, expression_statement; 33, identifier:Dict; 34, type_parameter; 35, string:"jsonrpc"; 36, string:"result"; 37, string:"error"; 38, string:"id"; 39, string:"code"; 40, string:"message"; 41, string:"data"; 42, identifier:OrderedDict; 43, argument_list; 44, assignment; 45, type; 46, type; 47, call; 48, subscript; 49, call; 50, identifier:str; 51, identifier:Any; 52, identifier:sorted; 53, argument_list; 54, identifier:req; 55, string:"error"; 56, identifier:OrderedDict; 57, argument_list; 58, call; 59, keyword_argument; 60, call; 61, attribute; 62, argument_list; 63, identifier:key; 64, lambda; 65, identifier:sorted; 66, argument_list; 67, identifier:response; 68, identifier:items; 69, lambda_parameters; 70, call; 71, call; 72, keyword_argument; 73, identifier:k; 74, attribute; 75, argument_list; 76, attribute; 77, argument_list; 78, identifier:key; 79, lambda; 80, identifier:root_order; 81, identifier:index; 82, subscript; 83, subscript; 84, identifier:items; 85, lambda_parameters; 86, call; 87, identifier:k; 88, integer:0; 89, identifier:response; 90, string:"error"; 91, identifier:k; 92, attribute; 93, argument_list; 94, identifier:error_order; 95, identifier:index; 96, subscript; 97, identifier:k; 98, integer:0
code: def sort_response(response: Dict[str, Any]) -> OrderedDict:
      """
      Sort the keys in a JSON-RPC response object.
  
      This has no effect other than making it nicer to read. Useful in Python 3.5 only,
      dictionaries are already sorted in newer Python versions.
  
      Example::
  
          >>> json.dumps(sort_response({'id': 2, 'result': 5, 'jsonrpc': '2.0'}))
          {"jsonrpc": "2.0", "result": 5, "id": 1}
  
      Args:
          response: Deserialized JSON-RPC response.
  
      Returns:
          The same response, sorted in an OrderedDict.
      """
      root_order = ["jsonrpc", "result", "error", "id"]
      error_order = ["code", "message", "data"]
      req = OrderedDict(sorted(response.items(), key=lambda k: root_order.index(k[0])))
      if "error" in response:
          req["error"] = OrderedDict(
              sorted(response["error"].items(), key=lambda k: error_order.index(k[0]))
          )
      return req