Bring an application to the foreground
Go talk to the Process Manager. FN GETFRONTPROCESS will get you the ProcessSerialNumber for the currently frontmost process. FN SETFRONTPROCESS notes that a process is to be brought to the front, and switches it on the next event.
Using these two functions you can rearrange the app list to your satisfaction.
This is an extract from a screen saver I wrote some time ago. If you want the whole source then email me directly.
LOCAL FN SetFrontProcess (@psnPtr&)
` SUBQ.L #2,sp ;clear space for osErr
` MOVE.L ^psnPtr&,-(sp) ;push psn ptr on stack
` DC.W $3F3C,$003B,$A88F ;trap number
` MOVE.W (sp)+,^osErr% ;D0 = osErr
END FN = osErr%