Skip to content

Commit

Permalink
moved the comment about sorting in different php versions to the usor…
Browse files Browse the repository at this point in the history
…t function call
  • Loading branch information
Fellan-91 committed May 15, 2024
1 parent 47bc13c commit 87c250d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions classes/class-get-portfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,11 +1184,6 @@ private static function get_rand_seed_session() {

/**
* Sort associative array by custom field.
* In some cases,
* The function may sort elements with the same values ​​differently in php 7 and php 8.
* This is due to the following change in how the usort function works.
* 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.
*
* @param array $array - Sortable array.
* @param string $field - Array field by which sorting will take place.
Expand All @@ -1209,6 +1204,13 @@ public static function sort_array_by_field( $array, $field, $order = 'desc' ) {
}
}

/**
* In some cases,
* The function may sort elements with the same values ​​differently in php 7 and php 8.
* This is due to the following change in how the usort function works.
* 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.
*/
usort(
$array,
function ( $a, $b ) use ( $field, $order ) {
Expand Down

0 comments on commit 87c250d

Please sign in to comment.