Fix sort and limit on index