Replace iterator with sorted list