1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-24 07:22:16 +01:00
Files
archived-doc-es/reference/array/sorting.xml
2025-06-28 23:32:30 +02:00

171 lines
5.2 KiB
XML

<?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></entry>
<entry>ascendente</entry>
<entry><function>arsort</function></entry>
</row>
<row>
<entry><function>arsort</function></entry>
<entry>valor</entry>
<entry></entry>
<entry>descendente</entry>
<entry><function>asort</function></entry>
</row>
<row>
<entry><function>krsort</function></entry>
<entry>clave</entry>
<entry></entry>
<entry>descendente</entry>
<entry><function>ksort</function></entry>
</row>
<row>
<entry><function>ksort</function></entry>
<entry>clave</entry>
<entry></entry>
<entry>ascendente</entry>
<entry><function>asort</function></entry>
</row>
<row>
<entry><function>natcasesort</function></entry>
<entry>valor</entry>
<entry></entry>
<entry>natural, insensible a la casilla</entry>
<entry><function>natsort</function></entry>
</row>
<row>
<entry><function>natsort</function></entry>
<entry>valor</entry>
<entry></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></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></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
-->