Sorting array ascending with duplicates at the end also sorted ascending
Do it in two phases.

Just sort the array in-place with your favorite in-place sorting algorithm
Scanning sorted array right to left, find the first DU subarray (where D is a bunch of duplicate values, and U is a tail of unique elements). Make it into UD. Keep going.

The second phase completes in O(n).
I'm trying to sort a array in place like [3,2,1,2,4,5,3] so that it is in sorted order ascending but with all duplicates grouped at the end in sorted order. So the result for the array would be [1,4,5,2,2,3,3]. How can I do this without using python built in sort()?