Sort DataFrame, moving duplicates to the end

I have a list containing number [1,1,2,2,3,3]. How can I sort this list to [1,2,3,1,2,3]?

Let me elaborate what it used for. I have a pandas dataframe

columnA columnB columnC
A       a        1       
A       a        1
A       b        2
A       b        2
B       a        1
B       a        1
B       b        2
B       b        2

I would like to have it reordered like:

columnA columnB columnC
A       a        1       
A       b        2
A       a        1
A       b        2
B       a        1
B       b        2
B       a        1
B       b        2

I have tried sort_values function, but it seems not works.

Answer

Here is a solution using GroupBy.cumcount to count duplicate values and use this count as a key to move duplicates to the end:

import pandas as pd

df = pd.read_csv('dataduplicates.csv')
df['duplicate_key'] = df.groupby('columnC').cumcount()
df.sort_values(['duplicate_key', 'columnC'], inplace=True)

print(df)
#   columnA columnB  columnC  duplicate_key
# 0       A       a        1              0
# 2       A       b        2              0
# 1       A       a        1              1
# 3       A       b        2              1
# 4       B       a        1              2
# 6       B       b        2              2
# 5       B       a        1              3
# 7       B       b        2              3