Since you are accessing elements at location right
and left
I assume that the initial call is as follows:
quickSort(list, 0, list.size()-1);
If the list is initially initialized as vector<int>{ 2, 1 }
the first call will evalute to
quickSort(list, 0, 1);
With left=0
and right=1
the first if
-statement will evaluate to
if(0 >= 1-1)
return;
and the function will return without swapping the two elements, even if the list is clearly unsorted.