public static function parse_sorter($text) { // parse the sorter $text = simplify_whitespace($text); if (preg_match('/\\A(\\d+)([a-z]*)\\z/i', $text, $m) || preg_match('/\\A([^-,+#]+)[,+#]([a-z]*)\\z/i', $text, $m)) { $sort = new ListSorter($m[1]); foreach (str_split(strtoupper($m[2])) as $x) { if ($x === "R" || $x === "N") { $sort->reverse = $x === "R"; } else { if ($x === "M") { $sort->score = "C"; } else { if (isset(self::$score_sorts[$x])) { $sort->score = $x; } } } } } else { $sort = PaperSearch::parse_sorter($text); } if ($sort->score === null) { $sort->score = self::default_score_sort(); } return $sort; }