Shape order macro

I want to order shape from

(i) front to back then

(ii) left to right then

(iii) top to bottom

How can I do that in macro.

Thanks in advance.