Sort the vector based on the frequency of elements

For example:
Input  1 3 5 3 6 1 2
Output 5 6 2 3 3 1 1 (the sequence of 5, 6, 2 can be changed, the sequence of 1, 3 can be changed too)