reference/array/functions/sort.xml
2ca090342977839edca2f7f4e52305a1b5da6095
...
...
@@ -3,21 +3,24 @@
3
3
<refentry xml:id="function.sort" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4
4
<refnamediv>
5
5
<refname>sort</refname>
6
-
<refpurpose>Sort an array</refpurpose>
6
+
<refpurpose>Sort an array in ascending order</refpurpose>
7
7
</refnamediv>
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
-
<type>bool</type><methodname>sort</methodname>
11
+
<type>true</type><methodname>sort</methodname>
12
12
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
13
-
<methodparam choice="opt"><type>int</type><parameter>sort_flags</parameter><initializer>SORT_REGULAR</initializer></methodparam>
13
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>SORT_REGULAR</constant></initializer></methodparam>
14
14
</methodsynopsis>
15
15
<para>
16
-
This function sorts an array. Elements will be arranged from
17
-
lowest to highest when this function has completed.
16
+
Sorts <parameter>array</parameter> in place by values
17
+
in ascending order.
18
18
</para>
19
19
&note.sort-unstable;
20
+
&note.no-key-association;
21
+
&note.reset-index;
20
22
</refsect1>
23
+

21
24
<refsect1 role="parameters">
22
25
&reftitle.parameters;
23
26
<para>
...
...
@@ -30,60 +33,37 @@
30
33
</para>
31
34
</listitem>
32
35
</varlistentry>
33
-
<varlistentry>
34
-
<term><parameter>sort_flags</parameter></term>
35
-
<listitem>
36
-
<para>
37
-
The optional second parameter <parameter>sort_flags</parameter>
38
-
may be used to modify the sorting behavior using these values:
39
-
</para>
40
-
<para>
41
-
Sorting type flags:
42
-
<itemizedlist>
43
-
<listitem>
44
-
<simpara><constant>SORT_REGULAR</constant> - compare items normally;
45
-
the details are described in the <link linkend="language.operators.comparison">comparison operators</link> section</simpara>
46
-
</listitem>
47
-
<listitem>
48
-
<simpara><constant>SORT_NUMERIC</constant> - compare items numerically</simpara>
49
-
</listitem>
50
-
<listitem>
51
-
<simpara><constant>SORT_STRING</constant> - compare items as strings</simpara>
52
-
</listitem>
53
-
<listitem>
54
-
<simpara>
55
-
<constant>SORT_LOCALE_STRING</constant> - compare items as
56
-
strings, based on the current locale. It uses the locale,
57
-
which can be changed using <function>setlocale</function>
58
-
</simpara>
59
-
</listitem>
60
-
<listitem>
61
-
<simpara>
62
-
<constant>SORT_NATURAL</constant> - compare items as strings
63
-
using "natural ordering" like <function>natsort</function>
64
-
</simpara>
65
-
</listitem>
66
-
<listitem>
67
-
<simpara>
68
-
<constant>SORT_FLAG_CASE</constant> - can be combined
69
-
(bitwise OR) with
70
-
<constant>SORT_STRING</constant> or
71
-
<constant>SORT_NATURAL</constant> to sort strings case-insensitively
72
-
</simpara>
73
-
</listitem>
74
-
</itemizedlist>
75
-
</para>
76
-
</listitem>
77
-
</varlistentry>
36
+
&sort.flags.parameter;
78
37
</variablelist>
79
38
</para>
80
39
</refsect1>
40
+

81
41
<refsect1 role="returnvalues">
82
42
&reftitle.returnvalues;
83
43
<para>
84
-
&return.success;
44
+
&return.true.always;
85
45
</para>
86
46
</refsect1>
47
+

48
+
<refsect1 role="changelog">
49
+
&reftitle.changelog;
50
+
<para>
51
+
<informaltable>
52
+
<tgroup cols="2">
53
+
<thead>
54
+
<row>
55
+
<entry>&Version;</entry>
56
+
<entry>&Description;</entry>
57
+
</row>
58
+
</thead>
59
+
<tbody>
60
+
&return.type.true;
61
+
</tbody>
62
+
</tgroup>
63
+
</informaltable>
64
+
</para>
65
+
</refsect1>
66
+

87
67
<refsect1 role="examples">
88
68
&reftitle.examples;
89
69
<para>
...
...
@@ -150,9 +130,9 @@ fruits[3] = orange20
150
130
The fruits have been sorted like <function>natcasesort</function>.
151
131
</para>
152
132
</refsect1>
133
+

153
134
<refsect1 role="notes">
154
135
&reftitle.notes;
155
-
&note.no-key-association;
156
136
<note>
157
137
<simpara>
158
138
Like most PHP sorting functions, <function>sort</function> uses an
...
...
@@ -167,22 +147,20 @@ fruits[3] = orange20
167
147
<simpara>
168
148
Be careful when sorting arrays with mixed types values because
169
149
<function>sort</function> can produce unexpected results,
170
-
if <parameter>sort_flags</parameter> is <constant>SORT_REGULAR</constant>,
150
+
if <parameter>flags</parameter> is <constant>SORT_REGULAR</constant>.
171
151
</simpara>
172
152
</warning>
173
153
</refsect1>
154
+

174
155
<refsect1 role="seealso">
175
156
&reftitle.seealso;
176
-
<para>
177
-
<simplelist>
178
-
<member><function>asort</function></member>
179
-
<member><function>rsort</function></member>
180
-
<member>&seealso.array.sorting;</member>
181
-
</simplelist>
182
-
</para>
157
+
<simplelist>
158
+
<member><function>rsort</function></member>
159
+
<member>&seealso.array.sorting;</member>
160
+
</simplelist>
183
161
</refsect1>
184
-
</refentry>
185
162

163
+
</refentry>
186
164
<!-- Keep this comment at the end of the file
187
165
Local variables:
188
166
mode: sgml
189
167