add priority sorting javascript