mysql> select array_sort([5,2,8,1,9,4], (x,y) ->
case when x % 2 = 0 and y % 2 = 0 then x - y
when x % 2 = 0 and y % 2 = 1 then -1
when x % 2 = 1 and y % 2 = 0 then 1
else x - y end);
+--------------------------------------------------------------------------------------------------------------------+
| array_sort([5, 2, 8, 1, 9, 4], (x, y) -> case when x % 2 = 0 and y % 2 = 0 then x - y when x % 2 = 0 and y % 2 = 1 then -1 when x % 2 = 1 and y % 2 = 0 then 1 else x - y end) |
+--------------------------------------------------------------------------------------------------------------------+
| [2, 4, 8, 1, 5, 9] |
+--------------------------------------------------------------------------------------------------------------------+