mirror of
https://github.com/php/doc-ja.git
synced 2026-04-23 16:08:07 +02:00
83b604fd28
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@249547 c90b9560-bf6c-de11-be94-00142212c4b1
181 lines
5.1 KiB
XML
181 lines
5.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision: 1.14 $ -->
|
|
<!-- EN-Revision: 1.26 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<refentry xml:id="function.sort" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>sort</refname>
|
|
<refpurpose>配列をソートする</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>sort</methodname>
|
|
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>sort_flags</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
この関数は配列をソートします。この関数が正常に終了すると、
|
|
各要素は低位から高位へ並べ替えられます。
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
入力の配列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>sort_flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
オプションの 2 番目のパラメータ <parameter>sort_flags</parameter>
|
|
は、以下の値によりソートの動作を修正するために使用することが可能です。
|
|
</para>
|
|
<para>
|
|
ソート型のフラグ:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara><constant>SORT_REGULAR</constant> - 通常通りに項目を比較
|
|
(型は変更しません)</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_NUMERIC</constant> - 数値的に項目を比較</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_STRING</constant> - 文字列として項目を比較</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_LOCALE_STRING</constant> - は、カレントのロケールに
|
|
に基づき比較を行います。PHP 4.4.0 と PHP 5.0.2で追加されました。
|
|
PHP 6 より前のバージョンではシステムロケールを使用します。これは
|
|
<function>setlocale</function> を使用して変更可能です。
|
|
PHP 6 以降では、<function>i18n_loc_set_default</function> 関数を
|
|
使用する必要があります。
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>4.0.0</entry>
|
|
<entry>
|
|
パラメータ <parameter>sort_flags</parameter> が追加されました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>sort</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$fruits = array("lemon", "orange", "banana", "apple");
|
|
sort($fruits);
|
|
foreach ($fruits as $key => $val) {
|
|
echo "fruits[" . $key . "] = " . $val . "\n";
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
fruits[0] = apple
|
|
fruits[1] = banana
|
|
fruits[2] = lemon
|
|
fruits[3] = orange
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
fruits はアルファベットの昇順にソートされました。
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.no-key-association;
|
|
<warning>
|
|
<simpara>
|
|
複数の型が混在する配列をソートする場合には、注意してください。
|
|
<function>sort</function> が予測不可能な結果を出力することがあります。
|
|
</simpara>
|
|
</warning>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>arsort</function></member>
|
|
<member><function>asort</function></member>
|
|
<member><function>ksort</function></member>
|
|
<member><function>rsort</function></member>
|
|
<member><function>usort</function></member>
|
|
<member><function>uksort</function></member>
|
|
<member><function>array_multisort</function></member>
|
|
<member><function>krsort</function></member>
|
|
<member><function>natsort</function></member>
|
|
<member><function>natcasesort</function></member>
|
|
</simplelist>
|
|
</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
|
|
-->
|