<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.arrayiterator.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'arrayiterator.uksort.php',
    1 => 'ArrayIterator::uksort',
    2 => 'Sort by keys using a user-defined comparison function',
  ),
  'up' => 
  array (
    0 => 'class.arrayiterator.php',
    1 => 'ArrayIterator',
  ),
  'prev' => 
  array (
    0 => 'arrayiterator.uasort.php',
    1 => 'ArrayIterator::uasort',
  ),
  'next' => 
  array (
    0 => 'arrayiterator.unserialize.php',
    1 => 'ArrayIterator::unserialize',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/spl/arrayiterator/uksort.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="arrayiterator.uksort" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ArrayIterator::uksort</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ArrayIterator::uksort</span> &mdash; <span class="dc-title">Sort by keys using a user-defined comparison function</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-arrayiterator.uksort-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ArrayIterator::uksort</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   This method sorts the elements by keys using a user-supplied comparison
   function.
  </p>
  <blockquote class="note"><p><strong class="note">Note</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-arrayiterator.uksort-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">callback</code></dt>
     <dd>
      <p class="para">
 The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
</p>
<div class="methodsynopsis dc-description"><span class="methodname"><span class="replaceable">callback</span></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$a</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$b</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

<div class="caution"><strong class="caution">Caution</strong>
 <p class="para">
  Returning <em>non-integer</em> values from the comparison
  function, such as <span class="type"><a href="language.types.float.php" class="type float">float</a></span>, will result in an internal cast to
  <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> of the callback&#039;s return value. So values such as
  <code class="literal">0.99</code> and <code class="literal">0.1</code> will both be cast to an
  integer value of <code class="literal">0</code>, which will compare such values as equal.
 </p>
</div>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-arrayiterator.uksort-returnvalues">
  <h3 class="title">Return Values</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-arrayiterator.uksort-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</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 seealso" id="refsect1-arrayiterator.uksort-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="arrayiterator.asort.php" class="methodname" rel="rdfs-seeAlso">ArrayIterator::asort()</a> - Sort entries by values</span></li>
    <li><span class="methodname"><a href="arrayiterator.ksort.php" class="methodname" rel="rdfs-seeAlso">ArrayIterator::ksort()</a> - Sort entries by keys</span></li>
    <li><span class="methodname"><a href="arrayiterator.natcasesort.php" class="methodname" rel="rdfs-seeAlso">ArrayIterator::natcasesort()</a> - Sort entries naturally, case insensitive</span></li>
    <li><span class="methodname"><a href="arrayiterator.natsort.php" class="methodname" rel="rdfs-seeAlso">ArrayIterator::natsort()</a> - Sort entries naturally</span></li>
    <li><span class="methodname"><a href="arrayiterator.uasort.php" class="methodname" rel="rdfs-seeAlso">ArrayIterator::uasort()</a> - Sort with a user-defined comparison function and maintain index association</span></li>
    <li><span class="function"><a href="function.uksort.php" class="function" rel="rdfs-seeAlso">uksort()</a> - Sort an array by keys using a user-defined comparison function</span></li>
   </ul>
  </p>
 </div>


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