2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

新入社員に基本のソートアルゴリズム(基本選択とかバブルソートとか)教えてるんだけど変わり種も伝えておこうかと書いてみた。

結構、有名なので知ってる方は多いと思いますが最大の値がが実行時間になってしまうのと負荷がかかってる状態だと想定外の結果になる可能性があるので実用では使わないでください。
※ sleep sort でググってください。

javascriptバージョン

var data = [1000,6,4,3,45,6,8,9,2,32,5,1];

for (i=0;i<data.length;i++) {
    setTimeout(function(v){console.log(v);}, data[i], data[i]);
}

結果

1
2
3
4
5
6
6
8
9
32
45
1000
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?