public static function sortByWordsCount($set_1, $set_2) { $first = str_word_count($set_1, 0, Analyzer::getCyrChars(["*"])); $second = str_word_count($set_2, 0, Analyzer::getCyrChars(["*"])); if ($first == $second) { return 0; } return $first > $second ? -1 : 1; }