diff --git a/classes/class-get-portfolio.php b/classes/class-get-portfolio.php index ab1ad149..92bbfa55 100644 --- a/classes/class-get-portfolio.php +++ b/classes/class-get-portfolio.php @@ -1215,10 +1215,12 @@ public static function sort_array_by_field( $array, $field, $order = 'desc' ) { $array, function ( $a, $b ) use ( $field, $order ) { // Primary comparison by field values. - $comparsion = 'asc' === $order ? strcmp( $a[ $field ], $b[ $field ] ) : strcmp( $b[ $field ], $a[ $field ] ); + if ( isset( $a[ $field ] ) && isset( $b[ $field ] ) ) { + $comparsion = 'asc' === $order ? strcmp( $a[ $field ], $b[ $field ] ) : strcmp( $b[ $field ], $a[ $field ] ); - if ( 0 !== $comparsion ) { - return $comparsion; + if ( 0 !== $comparsion ) { + return $comparsion; + } } // Secondary comparison by keys when values are equal.