Fix sort bug after refresh