PluginProbe
FakerPress / 0.7.2
FakerPress v0.7.2
0.9.2 trunk 0.1.0 0.1.1 0.1.2 0.1.3 0.5.2 0.5.3 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.7.0 0.7.1 0.7.2 0.8.0 0.9.0 0.9.1
fakerpress / src / functions / sorting.php

sorting.php in FakerPress 0.7.2, at src/functions/sorting.php

34 lines 586 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FakerPress;
4
5 /**
6 * Sorting function based on Priority
7 *
8 * @since 0.5.1
9 *
10 * @param object|array $a First Subject to compare.
11 * @param object|array $b Second subject to compare.
12 *
13 * @return int
14 */
15 function sort_by_priority( $a, $b ) {
16 if ( is_array( $a ) ) {
17 $a_priority = $a['priority'];
18 } else {
19 $a_priority = $a->priority;
20 }
21
22 if ( is_array( $b ) ) {
23 $b_priority = $b['priority'];
24 } else {
25 $b_priority = $b->priority;
26 }
27
28 if ( (int) $a_priority === (int) $b_priority ) {
29 return 0;
30 }
31
32 return (int) $a_priority < (int) $b_priority ? -1 : 1;
33 }
34