nodes: 0, module; 1, function_definition; 2, function_name:sort_nodes; 3, parameters; 4, block; 5, identifier:dom; 6, identifier:cmp_func; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, comment:"""
      Sort the nodes of the dom in-place, based on a comparison function.
      """; 11, call; 12, identifier:node; 13, call; 14, block; 15, attribute; 16, argument_list; 17, identifier:list; 18, argument_list; 19, expression_statement; 20, while_statement; 21, identifier:dom; 22, identifier:normalize; 23, call; 24, assignment; 25, boolean_operator; 26, block; 27, identifier:walk_dom; 28, argument_list; 29, identifier:prev_sib; 30, attribute; 31, identifier:prev_sib; 32, comparison_operator:cmp_func(prev_sib, node) == 1; 33, expression_statement; 34, expression_statement; 35, identifier:dom; 36, keyword_argument; 37, identifier:node; 38, identifier:previousSibling; 39, call; 40, integer:1; 41, call; 42, assignment; 43, identifier:elements_only; 44, True; 45, identifier:cmp_func; 46, argument_list; 47, attribute; 48, argument_list; 49, identifier:prev_sib; 50, attribute; 51, identifier:prev_sib; 52, identifier:node; 53, attribute; 54, identifier:insertBefore; 55, identifier:node; 56, identifier:prev_sib; 57, identifier:node; 58, identifier:previousSibling; 59, identifier:node; 60, identifier:parentNode
code: def sort_nodes(dom, cmp_func):
      """
      Sort the nodes of the dom in-place, based on a comparison function.
      """
      dom.normalize()
      for node in list(walk_dom(dom, elements_only=True)):
          prev_sib = node.previousSibling
          while prev_sib and cmp_func(prev_sib, node) == 1:
              node.parentNode.insertBefore(node, prev_sib)
              prev_sib = node.previousSibling