I'm guessing that you are trying to order by a column that contains text, but you don't want it to sort alphabetically. You can do this by using a CASE statement in the ORDER BY clause and giving each flag value a numeric value. It would look something like this, with all other codes sorting to the end:
ORDER BY (CASE WHEN flag='f' THEN 0 WHEN flag='I' THEN 1 WHEN flag='e' THEN 2 WHEN flag='r' THEN 3 ELSE 99 END)