implement quick sort for iteraor