Javascript native sort method code

后端 未结 3 1674
时光说笑
时光说笑 2020-12-04 01:58

Any idea how I can view the implementation of native javascript methods specifically the sort method. The reason why I am looking for this I am just wondering what the alg

3条回答
  •  死守一世寂寞
    2020-12-04 02:21

    Also does the implementation differ from browser to browser?

    Yes, the ECMAScript standard does not specify what algorithm should be used. AFAIK Mozillas SpiderMonkey uses mergesort and WebKit uses selection sort. What IE uses you probably have to ask someone at Microsoft, since it's closed source.

    And I'm willing to bet a couple of bucks that you cannot come up with a better/faster algorithm than the one implemented into the JavaScript engine of the browsers.

提交回复
热议问题