optimized quick sort