Can a military officer arrest a ranking officer?

This answer is specific to the US military, though it likely applies in most other counties as well, with the names of things modified as appropriate.
I assume you mean an MP (Military Policeman).
The answer is yes. MPs derive their authority ultimately from the Uniform Code of Military Justice, which "outranks" everyone in a "no man is above the law" sense. Any officer, even the CO of the base, can be arrested by an MP if he's violating the UCMJ.