sort iterator implemetation