タグ

sortに関するxnightsのブックマーク (3)

  • PHP - 以外の言語でPHPのsortを実装してみる。 : 404 Blog Not Found

    2009年02月27日17:00 カテゴリLightweight Languages PHP - 以外の言語でPHPのsortを実装してみる。 案外笑い事じゃないかも。特にJavaScript! PHPのsort関数は相当おかしい - hnwの日記 なんと、同じ要素を持つ配列をソートした結果が異なっています。こちらはまだいい具合にわざとらしいけど.... Perl [Run via CodePad] #!/usr/local/bin/perl use strict; use warnings; eval { # try Scalar::Util::looks_like_number() require Scalar::Util; Scalar::Util->import('looks_like_number'); }; if ($@) { # use regexp if not avail

    PHP - 以外の言語でPHPのsortを実装してみる。 : 404 Blog Not Found
  • PHPのsort関数は相当おかしい - hnwの日記

    追記(2009/02/28 15:35):ソートする配列の要素が数値または数値形式の文字列のみの場合は、<、==、>が推移律を満たすので、この記事のような矛盾は起こりません。念のため。 オヤジギャグがこらえられなくなったら立派なオヤジだと思います。それはさておき、今日はPHPのsort関数が不思議な挙動をする例を紹介します。 sort関数の紹介 sort ― 配列をソートする 説明 bool sort ( array &$array [, int $sort_flags= SORT_REGULAR ] ) この関数は配列をソートします。この関数が正常に終了すると、 各要素は低位から高位へ並べ替えられます。 PHP: sort - Manual マニュアルをみる限り普通のソート関数です。省略可能な2番目の引数の意味は次の通りです。 sort_flags オプションの 2 番目のパラメータ s

    PHPのsort関数は相当おかしい - hnwの日記
  • Animated Sorting Algorithms

    Discussion These pages show 8 different sorting algorithms on 4 different initial conditions. These visualizations are intended to: Show how each algorithm operates. Show that there is no best sorting algorithm. Show the advantages and disadvantages of each algorithm. Show that worse-case asymptotic behavior is not the deciding factor in choosing an algorithm. Show that the initial condition (inp

  • 1