non recursive version of quick sort