Application hierarchy - like in the heads-up menu

Many times I wanted sorted applications, as seen in the heads-up widget with :

Till now I found no way to access some sort of list with 1St, 2nd, 3rd process and so forth. Some ideas or suggestions?

Simple answer: In AS there is no way.

For other readers who are familiar with C and CoreFoundation:
From LaunchServices.framework (LS) you can get the application list by ‘last used’. This is undocumented, which means it is not supported and the symbol can be changed between OS versions which makes it fragile. But to give a complete answer there is a symbol in LS called __LSCopyApplicationArrayInFrontToBackOrder. This C-function will return an array of applications in the same order as cmd+tab. So the only two ways to get this is by either writing an OSAX or Objective-C wrapper class which can be used by AppleScrtipObjC.

You can find a great example here where the returned data is an CFArrayRef type which is an toll-free bridge Objective-C “object”. It’s a great starter and can be used in either an OSAX of Objective-C wrapper class.