Random thoughts - tall poppy Sorting

Ryuma Kojima
09/11/2025

shower sorts

I just finished my early action for uni and I have bit of free time right now. I saw stalin sort on the internet few years ago and I always wanted to make my own one. This is also 備忘録(This also serves as a personal memo) since I recently learned vector on C++ and I thought I can use what I learned there.

First, what is "tall poppy syndrome"? It's the concept I'm naming my sort after. Wikipedia defines it as:

"people with notable public success or achievements that are ostracised by others as a form of egalitarianism."

tall poppy sorting (First Attempt)

My idea was this: get the last '要素' (element) and if the vector.at(last - 1) is bigger than last one it is going to be vector.at(n) = vector.at(n + 1) - 1;

And here is the code:


#include 
using namespace std;

int main() {
    int n, sum = 0;
    cin >> n;
    vector data(n);
    
    for (int i = 0; i < n; i++) {
        cin >> data.at(i);
        sum += data.at(i);
    }
    
    int last = data.at(n - 1);
    
    for (int a = n - 2; a >= 0; a--) {
        if (data.at(a) > last) {
            data.at(a) = data.at(a + 1) - 1;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << data.at(i) << endl;
    }
}

      

But here is the problem. If the integers is 10, 1, 30 the output gonna be same. Not really sorting anything.

Revised Code (Second Attempt)

I revised my code to, though I know this is such a stupid idea, loop the whole process. If the set were10, 1, 30, first I define int last as 30 and kinda "sort" and then redefine last as 1 and re"sort" again and so on so it is going to be 10, 1, 300, 1, 30.

Here is the code:


#include 
using namespace std;

int main() {
    int n, sum = 0;
    cin >> n;
     vector data(n);
    
    for (int i = 0; i < n; i++) {
        cin >> data.at(i);
        sum += data.at(i);
    }
    
    for (int a = n - 2; a >= 0; a--) {
        if (data.at(a) > data.at(a + 1)) { 
            data.at(a) = data.at(a + 1) - 1;
        }
     }
    
    for (int i = 0; i < n; i++) {
        cout << data.at(i) << endl;
    }
}
      

It is order O(n) but not really practical anyway.