Implementing quick sort