mirror of
https://github.com/php/doc-es.git
synced 2026-03-24 23:42:11 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@334464 c90b9560-bf6c-de11-be94-00142212c4b1
173 lines
5.1 KiB
XML
173 lines
5.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 79a458220566758cd6abb064de988bebe9246028 Maintainer: jpberdejo Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<chapter xml:id="array.sorting" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<title>Ordenamiento de arrays</title>
|
|
<para>
|
|
PHP tiene varias funciones que se ocupan de ordenar arrays (matrices) y
|
|
este documento existe para ayudar a aclararlo todo.
|
|
</para>
|
|
<para>
|
|
Las principales diferencias son:
|
|
</para>
|
|
<para>
|
|
<simplelist>
|
|
<member>
|
|
Algunas ordenan basados en las key de la <type>array</type>,
|
|
mientras que otras por los valores: <literal>$array['key'] = 'valor';</literal>
|
|
</member>
|
|
<member>
|
|
Si se mantiene o no la correlación entre las key y los valores
|
|
después de la clasificación, lo cual puede significar que las key
|
|
se restablecen numéricamente (0,1,2 ...)
|
|
</member>
|
|
<member>
|
|
El orden de la clasificación: alfabético, de menor a mayor (ascendente),
|
|
de mayor a menor (descendente), numérico, natural, aleatorio o definido por el usuario
|
|
</member>
|
|
<member>
|
|
Nota: Todas estas funciones de clasificación actúan directamente sobre
|
|
la variable de array misma, en lugar de devolver un nuevo array ordenado.
|
|
</member>
|
|
<member>
|
|
Si alguna de estas funciones de clasificación evalúa a dos miembros como iguales,
|
|
entonces el orden no queda definido (la clasificación no es estable).
|
|
</member>
|
|
</simplelist>
|
|
</para>
|
|
<para>
|
|
<table>
|
|
<title>Atributos de las funciones de clasificación</title>
|
|
<tgroup cols="5">
|
|
<thead>
|
|
<row>
|
|
<entry>Nombre de la función</entry>
|
|
<entry>Ordena por</entry>
|
|
<entry>Mantiene asociación con las key</entry>
|
|
<entry>Orden de la clasificación</entry>
|
|
<entry>Funciones relacionadas</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry><function>array_multisort</function></entry>
|
|
<entry>valor</entry>
|
|
<entry>sí si es asociativa, no si es númerica</entry>
|
|
<entry>primer array u opciones de clasificación</entry>
|
|
<entry><function>array_walk</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>asort</function></entry>
|
|
<entry>valor</entry>
|
|
<entry>sí</entry>
|
|
<entry>menor a mayor</entry>
|
|
<entry><function>arsort</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>arsort</function></entry>
|
|
<entry>valor</entry>
|
|
<entry>sí</entry>
|
|
<entry>mayor a menor</entry>
|
|
<entry><function>asort</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>krsort</function></entry>
|
|
<entry>key</entry>
|
|
<entry>sí</entry>
|
|
<entry>mayor a menor</entry>
|
|
<entry><function>ksort</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>ksort</function></entry>
|
|
<entry>key</entry>
|
|
<entry>sí</entry>
|
|
<entry>menor a mayor</entry>
|
|
<entry><function>asort</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>natcasesort</function></entry>
|
|
<entry>valores</entry>
|
|
<entry>sí</entry>
|
|
<entry>natural, insensible a mayúsculas y minúsculas</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>mayor a menor</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>menor a mayor</entry>
|
|
<entry><function>rsort</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>uasort</function></entry>
|
|
<entry>valor</entry>
|
|
<entry>sí</entry>
|
|
<entry>definido por el usuario</entry>
|
|
<entry><function>uksort</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>uksort</function></entry>
|
|
<entry>key</entry>
|
|
<entry>sí</entry>
|
|
<entry>definido por el usuario</entry>
|
|
<entry><function>uasort</function></entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>usort</function></entry>
|
|
<entry>valor</entry>
|
|
<entry>no</entry>
|
|
<entry>definido por el 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
|
|
-->
|
|
|
|
|