added root sorting & double comparison fn