Reversing the order of up and downsampling When we are dealing with the problem of changing the sampling rate by a noninteger factor like L/M, we first need to the do the upsampling, and then the downsampling. 

My question is that under which condition can we reverse this order?
The problem with downsampling is that it can be lossy -- since you're reducing the sampling rate, you can introduce aliasing. So, you can reverse the order whenever downsampling does not result in aliasing.

For example, say your discrete-time signal $x[n]$ contains energy in frequencies up to $f_N/3$, where $f_N$ is the Nyquist frequency. Then, downsampling by a factor of 2 will not affect the signal: the "new" Nyquist frequency is $f_N/2$, so there is no aliasing.

See also Which order to perform downsampling and filtering?.