fs_sort_by_priority

Sorts an array by the value of the priority key.

Description

(int) fs_sort_by_priority( $a, $b ); 

Returns (int)

Parameters (2)

0. $a
The a.
1. $b
The b.

Usage

  1. if ( !function_exists( 'fs_sort_by_priority' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextgen-gallery/freemius/includes/fs-core-functions.php'; 
  3.  
  4. // The a. 
  5. $a = null; 
  6.  
  7. // The b. 
  8. $b = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = fs_sort_by_priority($a, $b); 
  12.  

Defined (1)

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

/freemius/includes/fs-core-functions.php  
  1. function fs_sort_by_priority( $a, $b ) { 
  2.  
  3. // If b has a priority and a does not, b wins. 
  4. if ( ! isset( $a['priority'] ) && isset( $b['priority'] ) ) { 
  5. return 1; 
  6. } // If b has a priority and a does not, b wins. 
  7. elseif ( isset( $a['priority'] ) && ! isset( $b['priority'] ) ) { 
  8. return - 1; 
  9. } // If neither has a priority or both priorities are equal its a tie. 
  10. elseif ( ( ! isset( $a['priority'] ) && ! isset( $b['priority'] ) ) || $a['priority'] === $b['priority'] ) { 
  11. return 0; 
  12.  
  13. // If both have priority return the winner. 
  14. return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;