[corlib] Fixed performance regression in qsort() functions
Many thanks to Martin Potter who both discovered this performance
regression, providing a test case, and proposing this patch/solution.
If most of the keys have identical values as the pivot, the partitions
would become largely lopsided resulting in a worst-case scenario runtime.
We can avoid this worst-case scenario by keeping the partitions better
balanced. To do this, we can modify the "closing-in of the walls" loops
to allow items with keys identical to the pivot to be swapped to the
higher-order partition (the previous implementation would greedily
keep them in the low-order partition).
As an added bonus, this also allows us to remove the code that was needed
to keep track of the pivot index.