Gradual iterator for sorting large cache datasets