Get Running Apps in Frontmost Date Order

The main forum contains a thread having to do with activating apps (here), and robertfern posted in this thread a very-helpful handler that gets running apps ordered from newest to oldest based on the order in which the apps were last frontmost. I thought this might be useful in a shortcut, and I’ve included that below.

Get Running Apps.shortcut (22.7 KB)

You can do something similar with native Shortcut actions, but the apps are ordered by launch date. The following shortcut has an intermittent bug which does not filter out apps that are not running. In my testing, this bug did not occur, but it may reappear.

Get Running Apps.shortcut (22.1 KB)