<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="ds-vector.sorted" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>Ds\Vector::sorted</refname>
  <refpurpose>Returns a sorted copy</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>Ds\Vector</type><methodname>Ds\Vector::sorted</methodname>
   <methodparam choice="opt"><type>callable</type><parameter>comparator</parameter></methodparam>
  </methodsynopsis>
  <para>
    Returns a sorted copy, using an optional <parameter>comparator</parameter> function.
  </para>

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
     <term><parameter>comparator</parameter></term>
     <listitem>
      &sort.callback.description;
     </listitem>
    </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
    Returns a sorted copy of the vector.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>Ds\Vector::sorted</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php
$vector = new \Ds\Vector([4, 5, 1, 3, 2]);

print_r($vector->sorted());
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
Ds\Vector Object
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)
]]>
   </screen>
  </example>
  <example>
   <title><function>Ds\Vector::sorted</function> example using a comparator</title>
   <programlisting role="php">
<![CDATA[
<?php
$vector = new \Ds\Vector([4, 5, 1, 3, 2]);

$sorted = $vector->sorted(function($a, $b) {
    return $b <=> $a;
});

print_r($sorted);
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
Ds\Vector Object
(
    [0] => 5
    [1] => 4
    [2] => 3
    [3] => 2
    [4] => 1
)
]]>
   </screen>
  </example>

 </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
-->
