Fixed sorting not updating the id numbers