Sort indexes by id