Help us understand the problem. What is going on with this article?

# スターリンソートとは

I came up with asingle pass O(n) sort algorithm I call StalinSort.
You iterate down the list of elements checking if they're in order.
Any element which is out of order is eliminated.
At the end you have asorted list.

また、同じ数字がある場合は残しています。
（例）`6, 2, 5, 7, 3, 8, 8, 4` -> `6, 7, 8, 8`

# 先駆者たち

すでにPythonで書いている人いるけど実装方法違うからいいよね！

# 実装

リスト内包表記で1行でした。
リスト内包表記については「python3と秘密のリスト内包表記」が非常に参考になりました。

stalinsort.py
```def stalinsort(targets):
return [(tmp.append(i), i)[1] for tmp in [[targets[0]]] for i in targets if i >= tmp[-1]]

original_list = [6, 2, 5, 7, 3, 8, 8, 4]
sorted_list = stalinsort(original_list)
print('original', original_list)
print('sorted', sorted_list)
```

```original [6, 2, 5, 7, 3, 8, 8, 4]
sorted [6, 7, 8, 8]
```

Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away