private function sortGroup(array $group)
{
if (empty($group)) {
return [];
}
if ($this->sortType == self::SORT_TYPE_LENGTH) {
usort($group, function ($a, $b) {
$cmp = strlen($b) - strlen($a);
if ($cmp === 0) {
$a = strtolower($a);
$b = strtolower($b);
$cmp = strcmp($b, $a);
}
return $cmp;
});
} elseif ($this->sortType == self::SORT_TYPE_ALPHABETIC) {
usort($group, function ($a, $b) {
$a = strtolower($a);
$b = strtolower($b);
$cmp = strcmp($b, $a);
if ($cmp === 0) {
$cmp = strlen($b) - strlen($a);
}
return $cmp;
});
}
if ($this->sortDirection == self::SORT_DIRECTION_ASC) {
$group = array_reverse($group);
}
return $group;
}