adding route sorting logic