jquery sorting almost working properly