Handling duplicate keys in quicksort
Use a swap function rather then repeating the three lines required to swap elements three times
Put spaces around your operators
You avoid recursing for the second partition. I don't think the performance gain from this is sufficient for the extra complexity in your code.


Rather then swapping before/after for the element equal to the pivot, count the number of elements equal to the pivot. Then when you sort the subarray make the one subarray shorter so as not to sort the elements equal to the pivot.

Another issue as Rafe has noted is that there are other issues besides duplicate keys that can cause a O(n^2) behavior. Your code doesn't handle any of those.