Quick sort algorithm for two arrays