How to sort ps output
The ps command is key to understanding what’s running on your Linux system and the resources that each process is using. It’s useful to know how to display the information that ps provides in whatever way helps you focus on the problem you’re trying to resolve. One aspect of this is being able to sort the output of the ps aux command by any column to highlight particular information, such as how much memory processes are using or how long they’ve been running.
The trick involves using the ps command’s –sort option and knowing how to specify the column that you want to use for the sort. By default, ps sorts by process IDs (PIDs), showing the smallest first. PID 1 will appear at the top of the list, right under the column headings. The rest will follow in numeric order.
Source:: Network World – Linux