[3,4,5]
?CREATE TABLE t(c VARCHAR(10), i INT);
INSERT INTO t VALUES ('key', 3), ('key', 5), ('key', 4);
SELECT JSON_ARRAYAGG(i) FROM t group by c ORDER by i;
SELECT JSON_ARRAYAGG(i) FROM (select c, i from t order by i) t1 group by c;
with t1 as (select c, i from t order by i)
SELECT JSON_ARRAYAGG(i) FROM t1 group by c;