<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.arrayobject.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'arrayobject.asort.php',
    1 => 'ArrayObject::asort',
    2 => 'Sort the entries by value',
  ),
  'up' => 
  array (
    0 => 'class.arrayobject.php',
    1 => 'ArrayObject',
  ),
  'prev' => 
  array (
    0 => 'arrayobject.append.php',
    1 => 'ArrayObject::append',
  ),
  'next' => 
  array (
    0 => 'arrayobject.construct.php',
    1 => 'ArrayObject::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/spl/arrayobject/asort.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="arrayobject.asort" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ArrayObject::asort</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ArrayObject::asort</span> &mdash; <span class="dc-title">Sort the entries by value</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-arrayobject.asort-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ArrayObject::asort</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code><a href="array.constants.php#constant.sort-regular">SORT_REGULAR</a></code></strong></span></span>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   Sorts the entries in ascending order,
   such that its keys maintain their correlation with the values they
   are associated with.
  </p>
  <p class="para">
   This is used mainly when sorting associative arrays where the actual
   element order is significant.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
 <p class="para">
  If two members compare as equal, they retain their original order.
  Prior to PHP 8.0.0, their relative order in the sorted array was undefined.
 </p>
</p></blockquote>

 </div>


 <div class="refsect1 parameters" id="refsect1-arrayobject.asort-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <dl>
   
  <dt><code class="parameter">flags</code></dt>
  <dd>
   <p class="para">
    The optional second parameter <code class="parameter">flags</code>
    may be used to modify the sorting behavior using these values:
   </p>
   <p class="para">
    Sorting type flags:
    <ul class="itemizedlist">
     <li class="listitem">
      <span class="simpara"><strong><code><a href="array.constants.php#constant.sort-regular">SORT_REGULAR</a></code></strong> - compare items normally;
      the details are described in the <a href="language.operators.comparison.php" class="link">comparison operators</a> section</span>
     </li>
     <li class="listitem">
      <span class="simpara"><strong><code><a href="array.constants.php#constant.sort-numeric">SORT_NUMERIC</a></code></strong> - compare items numerically</span>
     </li>
     <li class="listitem">
      <span class="simpara"><strong><code><a href="array.constants.php#constant.sort-string">SORT_STRING</a></code></strong> - compare items as strings</span>
     </li>
     <li class="listitem">
      <span class="simpara">
       <strong><code><a href="array.constants.php#constant.sort-locale-string">SORT_LOCALE_STRING</a></code></strong> - compare items as
       strings, based on the current locale. It uses the locale,
       which can be changed using <span class="function"><a href="function.setlocale.php" class="function">setlocale()</a></span>
      </span>
     </li>
     <li class="listitem">
      <span class="simpara">
       <strong><code><a href="array.constants.php#constant.sort-natural">SORT_NATURAL</a></code></strong> - compare items as strings
       using &quot;natural ordering&quot; like <span class="function"><a href="function.natsort.php" class="function">natsort()</a></span>
      </span>
     </li>
     <li class="listitem">
      <span class="simpara">
       <strong><code><a href="array.constants.php#constant.sort-flag-case">SORT_FLAG_CASE</a></code></strong> - can be combined
       (bitwise OR) with
       <strong><code><a href="array.constants.php#constant.sort-string">SORT_STRING</a></code></strong> or
       <strong><code><a href="array.constants.php#constant.sort-natural">SORT_NATURAL</a></code></strong> to sort strings case-insensitively
      </span>
     </li>
    </ul>
   </p>
  </dd>
 

  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-arrayobject.asort-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Always returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-arrayobject.asort-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Versione</th>
       <th>Descrizione</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
 <td>8.2.0</td>
 <td>
  The return type is <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> now; previously, it was <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>.
 </td>
</tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-arrayobject.asort-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>ArrayObject::asort()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$fruits </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"d" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"lemon"</span><span style="color: #007700">, </span><span style="color: #DD0000">"a" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"orange"</span><span style="color: #007700">, </span><span style="color: #DD0000">"b" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"banana"</span><span style="color: #007700">, </span><span style="color: #DD0000">"c" </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">"apple"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fruitArrayObject </span><span style="color: #007700">= new </span><span style="color: #0000BB">ArrayObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$fruits</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fruitArrayObject</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">asort</span><span style="color: #007700">();<br /><br />foreach (</span><span style="color: #0000BB">$fruitArrayObject </span><span style="color: #007700">as </span><span style="color: #0000BB">$key </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$val</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$key</span><span style="color: #DD0000"> = </span><span style="color: #0000BB">$val</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Il precedente esempio visualizzerà:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">c = apple
b = banana
d = lemon
a = orange</pre>
</div>
    </div>
    <div class="example-contents"><p>
     The fruits have been sorted in alphabetical order, and the key
     associated with each entry has been maintained.
    </p></div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-arrayobject.asort-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="arrayobject.ksort.php" class="methodname" rel="rdfs-seeAlso">ArrayObject::ksort()</a> - Sort the entries by key</span></li>
    <li><span class="methodname"><a href="arrayobject.natsort.php" class="methodname" rel="rdfs-seeAlso">ArrayObject::natsort()</a> - Sort entries using a &quot;natural order&quot; algorithm</span></li>
    <li><span class="methodname"><a href="arrayobject.natcasesort.php" class="methodname" rel="rdfs-seeAlso">ArrayObject::natcasesort()</a> - Sort an array using a case insensitive &quot;natural order&quot; algorithm</span></li>
    <li><span class="methodname"><a href="arrayobject.uasort.php" class="methodname" rel="rdfs-seeAlso">ArrayObject::uasort()</a> - Sort the entries with a user-defined comparison function and maintain key association</span></li>
    <li><span class="methodname"><a href="arrayobject.uksort.php" class="methodname" rel="rdfs-seeAlso">ArrayObject::uksort()</a> - Sort the entries by keys using a user-defined comparison function</span></li>
    <li><span class="function"><a href="function.asort.php" class="function" rel="rdfs-seeAlso">asort()</a> - Ordina un array e mantiene le associazioni degli indici</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>