mirror of
https://github.com/php/doc-de.git
synced 2026-03-26 16:22:10 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@338591 c90b9560-bf6c-de11-be94-00142212c4b1
249 lines
6.4 KiB
XML
249 lines
6.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: eda3b067eb85fcd307682aa8966d3c017cc29be2 Maintainer: simp Status: ready -->
|
|
<!-- CREDITS: tom, sammywg, wiesemann -->
|
|
|
|
<refentry xml:id="function.sort" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>sort</refname>
|
|
<refpurpose>Sortiert ein Array</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><initializer>SORT_REGULAR</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Diese Funktion sortiert ein Array. Die Elemente werden aufsteigend
|
|
vom niedrigsten zum höchsten Wert sortiert.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Das Eingabe-Array.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>sort_flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Der optionale zweite Parameter <parameter>sort_flags</parameter>
|
|
kann mit folgenden Werten genutzt werden, um das Sortierverhalten
|
|
zu ändern:
|
|
</para>
|
|
<para>
|
|
Sortiertypen-Flags:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara><constant>SORT_REGULAR</constant> - vergleiche Einträge
|
|
normal (ohne die Typen zu ändern)</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_NUMERIC</constant> - vergleiche Einträge
|
|
numerisch</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_STRING</constant> - vergleiche Einträge
|
|
als Strings</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_LOCALE_STRING</constant> - vergleiche
|
|
Einträge als Strings, basierend auf den aktuellen Locale-Einstellungen.
|
|
Es wird die System-Locale benutzt, die mittels <function>setlocale</function>
|
|
geändert werden kann.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara><constant>SORT_NATURAL</constant> - vergleicht mittels eines
|
|
Sortieralgorithmus für "natürlicher Reihenfolge" ähnlich zu
|
|
<function>natsort</function>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<constant>SORT_FLAG_CASE</constant> - kann kombiniert werden
|
|
(bitweises OR) mit
|
|
<constant>SORT_STRING</constant> oder
|
|
<constant>SORT_NATURAL</constant> um Strings unabhängig von Groß-
|
|
und Kleinschreibung zu sortieren
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.4.0</entry>
|
|
<entry>
|
|
Unterstützung für <constant>SORT_NATURAL</constant> und
|
|
<constant>SORT_FLAG_CASE</constant> als <parameter>sort_flags</parameter>
|
|
hinzugefügt
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>5.0.2</entry>
|
|
<entry>
|
|
<constant>SORT_LOCALE_STRING</constant> hinzugefügt
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>sort</function>-Beispiel</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$fruits = array("Zitrone", "Orange", "Banane", "Apfel");
|
|
sort($fruits);
|
|
foreach ($fruits as $key => $val) {
|
|
echo "fruits[" . $key . "] = " . $val . "\n";
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
fruits[0] = Apfel
|
|
fruits[1] = Banane
|
|
fruits[2] = Orange
|
|
fruits[3] = Zitrone
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Die Früchte wurden in alphabetischer Reihenfolge sortiert.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>sort</function>-Beispiel mit natürlicher Sortierung
|
|
ohne Beachtung der Groß- und Kleinschreibung</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$fruits = array(
|
|
"Orange1", "orange2", "Orange3", "orange20"
|
|
);
|
|
sort($fruits, SORT_NATURAL | SORT_FLAG_CASE);
|
|
foreach ($fruits as $key => $val) {
|
|
echo "fruits[" . $key . "] = " . $val . "\n";
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
fruits[0] = Orange1
|
|
fruits[1] = orange2
|
|
fruits[2] = Orange3
|
|
fruits[3] = orange20
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Die Früchte wurden wie durch <function>natcasesort</function> sortiert.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.no-key-association;
|
|
<note>
|
|
<simpara>
|
|
Wie die meisten PHP-Sortierfunktionen benutzt
|
|
<function>sort</function> eine Implementierung von
|
|
<link xlink:href="&url.wiki.quicksort;">Quicksort</link>.
|
|
Das Pivotelement wird aus der Mitte der Partition gewählt, was zu optimaler
|
|
Laufzeit für bereits sortierte Arrays führt. Das ist jedoch ein
|
|
Implementierungsdetail auf dass Sie sich nicht verlassen sollten.
|
|
</simpara>
|
|
</note>
|
|
<warning>
|
|
<simpara>
|
|
Seien Sie vorsichtig bei der Sortierung von Arrays mit
|
|
unterschiedlichen Typen, weil <function>sort</function>
|
|
zu unvorhersehbaren Ergebnissen kommen kann.
|
|
</simpara>
|
|
</warning>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>asort</function></member>
|
|
<member>&seealso.array.sorting;</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:"~/.phpdoc/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
|
|
-->
|