To add to @Deduplicator suggestions, I would recommend you improve your runtime. I mean there is nothing wrong in the implementation itself but currently you are using the last element of the array as pivot - this element can be the maximum or the minimum on each iteration making the complexity of this implementation in the worst case \$O(n^2)\$. However if you take the median as pivot in quicksort you are bound to do the job with the least operations as possible (at least asymptotically \$O(n\log n)\$). Be aware that in order to get to this you need an algorithm that finds a median in complexity of \$O(n)\$. There are quite a lot of information sources on the subject. You should take a look [here](https://en.wikipedia.org/wiki/Selection_algorithm#Median_selection_as_pivot_strategy).