def sort_nodes(dom, cmp_func):
dom.normalize()<EOL>for node in list(walk_dom(dom, elements_only=True)):<EOL><INDENT>prev_sib = node.previousSibling<EOL>while prev_sib and cmp_func(prev_sib, node) == <NUM_LIT:1>:<EOL><INDENT>node.parentNode.insertBefore(node, prev_sib)<EOL>prev_sib = node.previousSibling<EOL><DEDENT><DEDENT>
Sort the nodes of the dom in-place, based on a comparison function.