original_string: public static function arraySort(array &$array, $key = null, $dir = 0,
                                       $assoc = true)
      {
          /* Return if the array is empty. */
          if (empty($array)) {
              return;
          }
  
          /* If no key to sort by is specified, use the first key of the
           * first element. */
          if (is_null($key)) {
              $keys = array_keys(reset($array));
              $key = array_shift($keys);
          }
  
          /* Call the appropriate sort function. */
          $helper = new Horde_Array_Sort_Helper();
          $helper->key = $key;
          $function = $dir ? 'reverseCompare' : 'compare';
          if ($assoc) {
              uasort($array, array($helper, $function));
          } else {
              usort($array, array($helper, $function));
          }
      }
code: public static function arraySort(array &$array, $key = null, $dir = 0,
                                       $assoc = true)
      {
          /* Return if the array is empty. */
          if (empty($array)) {
              return;
          }
  
          /* If no key to sort by is specified, use the first key of the
           * first element. */
          if (is_null($key)) {
              $keys = array_keys(reset($array));
              $key = array_shift($keys);
          }
  
          /* Call the appropriate sort function. */
          $helper = new Horde_Array_Sort_Helper();
          $helper->key = $key;
          $function = $dir ? 'reverseCompare' : 'compare';
          if ($assoc) {
              uasort($array, array($helper, $function));
          } else {
              usort($array, array($helper, $function));
          }
      }
code_tokens: public static function arraySort ( array & $ array , $ key = null , $ dir = 0 , $ assoc = true ) { /* Return if the array is empty. */ if ( empty ( $ array ) ) { return ; } /* If no key to sort by is specified, use the first key of the
           * first element. */ if ( is_null ( $ key ) ) { $ keys = array_keys ( reset ( $ array ) ) ; $ key = array_shift ( $ keys ) ; } /* Call the appropriate sort function. */ $ helper = new Horde_Array_Sort_Helper ( ) ; $ helper -> key = $ key ; $ function = $ dir ? 'reverseCompare' : 'compare' ; if ( $ assoc ) { uasort ( $ array , array ( $ helper , $ function ) ) ; } else { usort ( $ array , array ( $ helper , $ function ) ) ; } }
docstring: Sorts an array on a specified key. If the key does not exist,
  defaults to the first key of the array.
  
  @param array &$array   The array to be sorted, passed by reference.
  @param string $key     The key by which to sort. If not specified then
  the first key is used.
  @param integer $dir    Sort direction:
  0 = ascending (default)
  1 = descending
  @param boolean $assoc  Keep key value association?
docstring_tokens: Sorts an array on a specified key . If the key does not exist defaults to the first key of the array .