Date: 08/22/00
- Next message: Daniel Beckham: "[PHP-DOC] cvs: phpdoc /en/functions strings.xml"
- Previous message: Daniel Beckham: "[PHP-DOC] cvs: phpdoc /en/functions session.xml"
- Next in thread: Ron Chmara: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
danbeck Tue Aug 22 18:53:06 2000 EDT
Modified files:
/phpdoc/en/functions array.xml
Log:
added natsort() and natcasesort()
Index: phpdoc/en/functions/array.xml
diff -u phpdoc/en/functions/array.xml:1.24 phpdoc/en/functions/array.xml:1.25
--- phpdoc/en/functions/array.xml:1.24 Mon Aug 21 10:54:00 2000
+++ phpdoc/en/functions/array.xml Tue Aug 22 18:53:05 2000
@@ -1823,6 +1823,120 @@
</refsect1>
</refentry>
+ <refentry id="function.natsort">
+ <refnamediv>
+ <refname>natsort</refname>
+ <refpurpose>
+ Sort an array using a "natural order" algorithm
+ </refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>void <function>natsort</function></funcdef>
+ <paramdef>array <parameter>array</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ This function implements a sort algorithm that orders
+ alphanumeric strings in the way a human being would. This is
+ described as a "natural ordering". An example of the difference
+ between this algorithm and the regular computer string sorting
+ algorithms (used in <function>sort</function>) can be seen below:
+ </para>
+ <para>
+ <example>
+ <title><function>natsort</function> example</title>
+ <programlisting role="php">
+$array1 = $array2 = array ("img12.png","img10.png","img2.png","img1.png");
+
+sort($array1);
+echo "Standard sorting\n";
+print_r($array1);
+
+natsort($array2);
+echo "\nNatural order sorting\n";
+print_r($array2);
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ The code above will generate the following output:
+ </para>
+ <para>
+ <informalexample>
+ <programlisting>
+Standard sorting
+Array
+(
+ [0] => img1.png
+ [1] => img10.png
+ [2] => img12.png
+ [3] => img2.png
+)
+
+Natural order sorting
+Array
+(
+ [3] => img1.png
+ [2] => img2.png
+ [1] => img10.png
+ [0] => img12.png
+)
+ </programlisting>
+ </informalexample>
+ For more infomation see: Martin Pool's <ulink
+ url="&url.strnatcmp;">Natural Order String Comparison</ulink>
+ page.
+ </para>
+ <para>
+ See also <function>natcasesort</function>,
+ <function>strnatcmp</function> and
+ <function>strnatcasecmp</function>.
+ </para>
+ </refsect1>
+ </refentry>
+
+ <refentry id="function.natcasesort">
+ <refnamediv>
+ <refname>natcasesort</refname>
+ <refpurpose>
+ Sort an array using a case insensitive "natural order" algorithm
+ </refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>void <function>natcasesort</function></funcdef>
+ <paramdef>array <parameter>array</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ This function implements a sort algorithm that orders
+ alphanumeric strings in the way a human being would. This is
+ described as a "natural ordering".
+ </para>
+ <para>
+ <function>natcasesort</function> is a case insensitive version of
+ <function>natsort</function>. See <function>natsort</function>
+ for an example of the difference between this algorithm and the
+ regular computer string sorting algorithms.
+ </para>
+ <para>
+ For more infomation see: Martin Pool's <ulink
+ url="&url.strnatcmp;">Natural Order String Comparison</ulink>
+ page.
+ </para>
+ <para>
+ See also <function>natsort</function>,
+ <function>strnatcmp</function> and
+ <function>strnatcasecmp</function>.
+ </para>
+ </refsect1>
+ </refentry>
+
<refentry id="function.next">
<refnamediv>
<refname>next</refname>
- Next message: Daniel Beckham: "[PHP-DOC] cvs: phpdoc /en/functions strings.xml"
- Previous message: Daniel Beckham: "[PHP-DOC] cvs: phpdoc /en/functions session.xml"
- Next in thread: Ron Chmara: "[PHP-DOC] cvs: phpdoc /en/functions array.xml"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

