タグ

関連タグで絞り込む (0)

  • 関連タグはありません

タグの絞り込みを解除

arrayとsortに関するedvakfのブックマーク (1)

  • comparefn - ellaneous

    Array.prototype.sort が受け取る比較関数は comparefn が undefined でないならば、それは 2 個の引数 x と y を受け付け、 x < y ならば負の値、 x = y ならば 0、 x > y ならば正の値を返す関数であるべきである。 http://www2u.biglobe.ne.jp/~oz-07ams/prog/ecma262r3/15-4_Array_Objects.html#section-15.4.4.11 という仕様で,これを真面目に書くと // sorting by 'str' property arr.sort(function(x, y){ return x.str > y.str ? -1 : x.str < y.str ? 1 : 0 } のようになりえらく辛気臭い。 来ソートするために必要な情報はその並びが正しいか否かの

    comparefn - ellaneous
  • 1