You can't. The order of query results is undefined if you don't use an explicit ORDER BY
clause:
You can use ORDER BY in a SELECT statement to control the order of the query results. There is no guarantee of the order of results unless you use an ORDER BY clause in a query.
ORDER BY
sorts by the value of the field, not by the order of specified parameters in the query.
If you need your results ordered in a specific way that does not correspond to sorting by any field in a normal lexicographic/numeric/datewise sort, consider implementing a wrapper class in Apex that implements the Comparable
interface to encapsulate your custom logic. You can then call sort()
on a list of wrapper objects.
This approach is demonstrated in the documentation, here, with Opportunities, but structurally your solution would be the same.