Using CASE is not very portable, because you need to know all the values ββand the order you want to sort in advance. The cleanest way is to use an array for the values ββand sort by the index of the element in the array.
Postgres .
CREATE OR REPLACE FUNCTION idx(anyarray, anyelement)
RETURNS int AS
$$
SELECT i FROM (
SELECT generate_series(array_lower($1,1),array_upper($1,1))
) g(i)
WHERE $1[i] = $2
LIMIT 1;
$$ LANGUAGE sql IMMUTABLE;
SELECT *
FROM foo
ORDER BY idx ( ['Freshman', 'Sophomore', 'Junior', 'Senior'], foo.grade_level)