advantage_sort_array

The Advantage advantage sort array function.

Description

advantage_sort_array( &$array, $key ); 

Parameters (2)

0. $array
The array.
1. $key
The key.

Usage

  1. if ( !function_exists( 'advantage_sort_array' ) ) { 
  2. require_once '/inc/lib-general.php'; 
  3.  
  4. // The array. 
  5. $array = &$array; 
  6.  
  7. // The key. 
  8. $key = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = advantage_sort_array($array, $key); 
  12.  

Defined (1)

The function is defined in the following location(s).

/inc/lib-general.php  
  1. function advantage_sort_array( &$array, $key ) { 
  2. $sorter = array(); 
  3. $ret = array(); 
  4. reset( $array ); 
  5. foreach ( $array as $ii => $va ) { 
  6. $sorter[ $ii ] = $va[ $key ]; 
  7. asort( $sorter ); 
  8. foreach ( $sorter as $ii => $va ) { 
  9. $ret[ $ii ] = $array[ $ii ]; 
  10. $array = $ret;