fixed sorting of DOM nodes

Never try this at home !!