javascript - Array.sort stability in different browsers -
array.sort sorting stability in different browsers
this old question, think helpful if collect recent data here. please click fiddle
and share results.
fiddle code:
a = [] for(var = 0; < 1000; i++) { a.push({'key':100 + math.round(math.random() * 100), 'val': + 1000 }) } a.sort(function(x, y) { return x.key - y.key }) b = [] for(var = 0; < 1000; i++) { b.push(a[i].key * 10000 + a[i].val); } c = b.slice(0) b.sort() stable = (b.join() === c.join()) document.body.innerhtml = navigator.useragent.tostring() + "<br>" + (stable ? "stable": "unstable")
stability browser os full ua string unstable safari 5.3 os x lion (10.7.5) mozilla/5.0 (macintosh; intel mac os x 10_7_5) applewebkit/536.29.13 (khtml, gecko) version/6.0.4 safari/536.29.13 stable firefox 15.0.1 os x lion mozilla/5.0 (macintosh; intel mac os x 10.7; rv:15.0) gecko/20100101 firefox/15.0.1 unstable chrome 21 os x lion (10.7.5) mozilla/5.0 (macintosh; intel mac os x 10_7_5) applewebkit/537.1 (khtml, gecko) chrome/21.0.1180.79 safari/537.1 stable firefox 16 win 7 mozilla/5.0 (windows nt 6.1; rv:16.0) gecko/20100101 firefox/16.0 unstable chrome 26 win 7 x64 mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.31 (khtml, gecko) chrome/26.0.1410.64 safari/537.31 unstable ie 9.0 win 7 x64 mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; wow64; trident/5.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; .net4.0c; infopath.3; .net4.0e) stable firefox 20 win 7 x64 mozilla/5.0 (windows nt 6.1; wow64; rv:20.0) gecko/20100101 firefox/20.0 unstable ie 10 win 7 mozilla/5.0 (compatible; msie 10.0; windows nt 6.1; trident/6.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; infopath.3; .net4.0c; .net4.0e) unstable chrome 26 win 7 mozilla/5.0 (windows nt 6.1) applewebkit/537.31 (khtml, gecko) chrome/26.0.1410.64 safari/537.31 stable firefox 20 win 8 x64 mozilla/5.0 (windows nt 6.2; wow64; rv:20.0) gecko/20100101 firefox/20.0 unstable ie 10 win 8 x64 mozilla/5.0 (compatible; msie 10.0; windows nt 6.2; wow64; trident/6.0; .net4.0e; .net4.0c; .net clr 3.5.30729; .net clr 2.0.50727; .net clr 3.0.30729; tablet pc 2.0) unstable chrome 26 win 8 x64 mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.31 (khtml, gecko) chrome/26.0.1410.64 safari/537.31 unstable opera 12.15 win 8 x64 opera/9.80 (windows nt 6.2; wow64) presto/2.12.388 version/12.15 stable firefox 20 ubuntu mozilla/5.0 (x11; ubuntu; linux x86_64; rv:20.0) gecko/20100101 firefox/20.0 unstable chrome 26 mozilla/5.0 (x11; linux x86_64) applewebkit/537.31 (khtml, gecko) chrome/26.0.1410.63 safari/537.31 unstable chrome 20 win 7 x64 mozilla/5.0 (windows nt 6.1; wow64) applewebkit/536.11 (khtml, gecko) chrome/20.0.1132.57 safari/536.11 unstable chrome 28 win 8 x64 mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml, gecko) chrome/28.0.1500.72 safari/537.36
Comments
Post a Comment