Implementing quick sort algorithm