mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-26 01:42:09 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@148762 c90b9560-bf6c-de11-be94-00142212c4b1
104 lines
2.9 KiB
XML
104 lines
2.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- splitted from ./fr/functions/array.xml, last change in rev 1.30 -->
|
|
<!-- last change to 'sort' in en/ tree in rev 1.2 -->
|
|
<refentry id="function.sort">
|
|
<refnamediv>
|
|
<refname>sort</refname>
|
|
<refpurpose>Trie un tableau</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>sort</methodname>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>sort_flags</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>sort</function> trie le tableau <parameter>array</parameter>. Les
|
|
éléments seront triés du plus petit au plus grand.
|
|
<example>
|
|
<title>Exemple avec <function>sort</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$fruits = array("papaye","orange","banane","ananas");
|
|
sort ($fruits);
|
|
reset ($fruits);
|
|
while (list ($key, $val) = each ($fruits)) {
|
|
echo "fruits[".$key."] = ".$val."\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
Cet exemple va afficher :
|
|
<computeroutput>
|
|
<![CDATA[
|
|
fruits[0] = ananas
|
|
fruits[1] = banane
|
|
fruits[2] = orange
|
|
fruits[3] = papaye
|
|
]]>
|
|
</computeroutput>
|
|
Les fruits ont été classés dans l'ordre alphabétique.
|
|
</para>
|
|
<para>
|
|
Le paramètre optionnel <parameter>sort_flags</parameter>
|
|
peut être utilisé pour modifier le comportement de trie en
|
|
utilisant ces valeurs :
|
|
</para>
|
|
<para>
|
|
Constantes de type de tri :
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara><constant>SORT_REGULAR</constant> : compare les éléments normalement</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_NUMERIC</constant> : compare les éléments numériquement</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_STRING</constant> : compare les éléments comme des chaînes de caractères</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Le second paramètre a été ajouté en &php; 4.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
Voir aussi
|
|
<function>arsort</function>,
|
|
<function>asort</function>,
|
|
<function>ksort</function>,
|
|
<function>natsort</function>,
|
|
<function>natcasesort</function>,
|
|
<function>rsort</function>,
|
|
<function>usort</function>,
|
|
<function>array_multisort</function> et
|
|
<function>uksort</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|