diff --git a/Editor/Options.php b/Editor/Options.php index fa940cf..01202d9 100644 --- a/Editor/Options.php +++ b/Editor/Options.php @@ -334,9 +334,20 @@ public function exec($db) // Only sort if there was no SQL order field if (!$this->_order) { usort($out, static function ($a, $b) { - return is_numeric($a['label']) && is_numeric($b['label']) ? - ($a['label'] * 1) - ($b['label'] * 1) : - strcmp($a['label'], $b['label']); + $aLabel = $a['label']; + $bLabel = $b['label']; + + if ($aLabel === null) { + $aLabel = ''; + } + + if ($bLabel === null) { + $bLabel = ''; + } + + return is_numeric($aLabel) && is_numeric($bLabel) ? + ($aLabel * 1) - ($bLabel * 1) : + strcmp($aLabel, $bLabel); }); } diff --git a/Editor/SearchBuilderOptions.php b/Editor/SearchBuilderOptions.php index 500be20..73c3553 100644 --- a/Editor/SearchBuilderOptions.php +++ b/Editor/SearchBuilderOptions.php @@ -323,9 +323,20 @@ public function exec($field, $editor, $http, $fields, $leftJoinIn) // Only sort if there was no SQL order field if (!$this->_order) { usort($out, static function ($a, $b) { - return is_numeric($a['label']) && is_numeric($b['label']) ? - ($a['label'] * 1) - ($b['label'] * 1) : - strcmp($a['label'], $b['label']); + $aLabel = $a['label']; + $bLabel = $b['label']; + + if ($aLabel === null) { + $aLabel = ''; + } + + if ($bLabel === null) { + $bLabel = ''; + } + + return is_numeric($aLabel) && is_numeric($bLabel) ? + ($aLabel * 1) - ($bLabel * 1) : + strcmp($aLabel, $bLabel); }); }