Need to resort table elements after compsoting to ensure DTD order