-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathsorting.xml
More file actions
170 lines (170 loc) · 5.17 KB
/
sorting.xml
File metadata and controls
170 lines (170 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: d1df62fe77b6cb0676d064e8e63ee2c3304d4260 Maintainer: PhilDaiguille Status: ready -->
<!-- Reviewed: no -->
<chapter xml:id="array.sorting" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Ordenación de arrays</title>
<para>
PHP dispone de numerosas funciones para ordenar arrays,
y esta sección del manual va a ayudar a comprenderlas.
</para>
<para>
Las diferencias principales son:
</para>
<para>
<simplelist>
<member>
Algunos de los ordenamientos de array están basados en las claves, mientras que
otros están basados en los valores:
<literal>$array['clave'] = 'valor';</literal>
</member>
<member>
Algunos ordenamientos mantienen la correlación entre las claves
y los valores, y otros no, lo que significa que las claves
suelen ser reasignadas numéricamente (0,1,2 ...)
</member>
<member>
El orden de la ordenación puede ser: alfabético, ascendente, descendente,
numérico, natural, aleatorio, o definido por el usuario.
</member>
<member>
Nota: todas estas funciones de ordenación trabajan sobre el array
mismo, a diferencia de la práctica normal que sería devolver el array ordenado.
</member>
<member>
Si una de estas funciones de ordenación evalúa 2 miembros como iguales,
entonces conservan el orden original.
Anterior a PHP 8.0.0, su orden era indefinido (la ordenación no era estable).
</member>
</simplelist>
</para>
<para>
<table>
<title>Atributos de funciones de ordenación</title>
<tgroup cols="5">
<thead>
<row>
<entry>Nombre de la función</entry>
<entry>Ordenación por</entry>
<entry>Asociación clave-valor</entry>
<entry>Orden de ordenación</entry>
<entry>Funciones asociadas</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>array_multisort</function></entry>
<entry>valor</entry>
<entry>claves <type>string</type> sí, claves <type>int</type> no</entry>
<entry>primer array, o bien opciones de ordenación</entry>
<entry><function>array_walk</function></entry>
</row>
<row>
<entry><function>asort</function></entry>
<entry>valor</entry>
<entry>sí</entry>
<entry>ascendente</entry>
<entry><function>arsort</function></entry>
</row>
<row>
<entry><function>arsort</function></entry>
<entry>valor</entry>
<entry>sí</entry>
<entry>descendente</entry>
<entry><function>asort</function></entry>
</row>
<row>
<entry><function>krsort</function></entry>
<entry>clave</entry>
<entry>sí</entry>
<entry>descendente</entry>
<entry><function>ksort</function></entry>
</row>
<row>
<entry><function>ksort</function></entry>
<entry>clave</entry>
<entry>sí</entry>
<entry>ascendente</entry>
<entry><function>asort</function></entry>
</row>
<row>
<entry><function>natcasesort</function></entry>
<entry>valor</entry>
<entry>sí</entry>
<entry>natural, insensible a la casilla</entry>
<entry><function>natsort</function></entry>
</row>
<row>
<entry><function>natsort</function></entry>
<entry>valor</entry>
<entry>sí</entry>
<entry>natural</entry>
<entry><function>natcasesort</function></entry>
</row>
<row>
<entry><function>rsort</function></entry>
<entry>valor</entry>
<entry>no</entry>
<entry>descendente</entry>
<entry><function>sort</function></entry>
</row>
<row>
<entry><function>shuffle</function></entry>
<entry>valor</entry>
<entry>no</entry>
<entry>aleatorio</entry>
<entry><function>array_rand</function></entry>
</row>
<row>
<entry><function>sort</function></entry>
<entry>valor</entry>
<entry>no</entry>
<entry>ascendente</entry>
<entry><function>rsort</function></entry>
</row>
<row>
<entry><function>uasort</function></entry>
<entry>valor</entry>
<entry>sí</entry>
<entry>Definido por una función de usuario</entry>
<entry><function>uksort</function></entry>
</row>
<row>
<entry><function>uksort</function></entry>
<entry>clave</entry>
<entry>sí</entry>
<entry>Definido por una función de usuario</entry>
<entry><function>uasort</function></entry>
</row>
<row>
<entry><function>usort</function></entry>
<entry>valor</entry>
<entry>no</entry>
<entry>Definido por una función de usuario</entry>
<entry><function>uasort</function></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</chapter>
<!-- 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
-->