WITH ids(id, sort) AS ( VALUES ('foo', 1), ('bar', 2), ('baz', 3) ) SELECT id FROM ids ORDER BY sort;