LoginSignup
0
0

More than 5 years have passed since last update.

ニワトリが先かタマゴが先かを確認する

Last updated at Posted at 2018-10-17

はじめに

先日、下記のツイートを見つけました。

やってみる

Python

Google Colaboratory ならPythonが使える。
ニワトリタマゴ.png

sorted(['🥚', '🐔'])
['🐔', '🥚']

結果はニワトリが先となった。

Javascript

ChromeのF12キーでConsoleを使えば、Javascriptが使える。
ニワトリタマゴ2.png

['🥚', '🐔'].sort()
(2) ['🐔', '🥚']

結果はニワトリが先となった。

CSharp

CodingGround はオンライン上で様々なプログラム言語が使えるサイトである。ここで「C#」を選択した。

ニワトリタマゴ3.png

using System.IO;
using System;

class Program
{
    static void Main()
    {
        string[] ary = new string[] {"🥚", "🐔"};
        Array.Sort(ary);
        foreach(var s in ary){
            Console.Write(s);
        }
    }
}

結果はタマゴが先となった。うーむ・・・、教えて偉い人

【2018/10/18追記】
Visual StudioのC#6.0上では、ニワトリが先になりました。Mono環境が古いからかな。

理由

文字コードでニワトリが先に登録されているからです。C#の結果は失敗ですけど。

Unicode 絵文字 名前 採用
U+1F414 🐔 にわとり(chicken) Unicode 6.0(2010)
U+1F95A 🥚 たまご(egg) Unicode 9.0(2016)

漢字

ちなみに漢字だとどうなるか、日本語と中国語でやってみました。

['', ''].sort()
(2) ["", ""]
['', ''].sort()
(2) ['', '']

結果はどちらでもタマゴが先となります。

最後に

これがいわゆるゴミ記事ってやつですね。

0
0
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
0
0