Sorting alphabetically - first Cyrillic, then Latin

Hello everyone, please tell me how to solve the problem.
There is an output of resources through the “mFilter2” snippet.
Sorting by headings in alphabetical order has been implemented.
sorting works like this: first, the Latin alphabet from a to z, and then the Cyrillic from а to я. It is necessary, on the contrary, so that the resources with the kerrill are the first.
Thanks in advance)

I think the exact sorting order typically depends on the collation that’s used in the database.

Perhaps, but unfortunately there is no access to the database.
There is a MySQL function that allows you to specify sorting via the built-in REGEXP operator.
You need to access the database through a snippet so that the resulting SQL looks like this:
SELECT * FROM modx_site_content ORDER BY IF(pagetitle REGEXP “^[А-Яа-я]”, 0, 1), pagetitle
Of all the options that I have tried, this one seems to be the most realistic.
But I can’t figure out how to build a query from a snippet. ((

$query = $modx->newQuery('modResource');
$query->sortby('IF(pagetitle REGEXP "^[А-Яа-я]", 0, 1), pagetitle');
$resources = $modx->getCollection('modResource',$query);
foreach($resources as $r){


$stmt = $modx->prepare('SELECT * FROM modx_site_content ORDER BY IF(pagetitle REGEXP "^[А-Яа-я]", 0, 1), pagetitle');
$resources = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($resources as $r) {
1 Like