After running top, do SHIFT + m (i.e. Uppercase M).
From man top
SORTING of task window For compatibility, this top supports most of the former top sort keys. Since this is primarily a service to former top users, these commands do not appear on any help screen. command sorted-field supported A start time (non-display) No M %MEM Yes N PID Yes P %CPU Yes T TIME+ Yes
So SHIFT + t would sort by running time.
Once you have the pid and want to investigate further, do ps -o cmd fp PID to find out what’s the corresponding command.
Ref:
https://unix.stackexchange.com/questions/128953/how-to-display-top-results-sorted-by-memory-usage-in-real-time
https://stackoverflow.com/questions/4802481/how-to-see-top-processes-sorted-by-actual-memory-usage
https://serverfault.com/questions/479460/find-command-from-pid