As the other answer mentions: the query you posted has nothing about what order you’d like your results, just which results you’d like to get.
To order your results, I would use ORDER BY FIELD()
:
SELECT * FROM foo f where f.id IN (2, 3, 1)
ORDER BY FIELD(f.id, 2, 3, 1);
The argument list to FIELD
can be variable length.