modified sort dom implementation to support safari and ff