There is no way to do this directly in the parameters of the top command.
Man top wrote
NAME
Top-display Linux Tasks
Synopsis
TOP-HV | -bchiss-d delay-n iterations-p pid [, PID ...]
The traditional switches '-' and whitespace are optional.
-b:batch mode operation
-c:command Line/program Name Toggle
-d:delay time interval as:-D ss.tt (seconds.tenths)
-h:help
-h:threads Toggle
-i:idle Processes Toggle
-n:number of iterations limit as:-N number
-u:monitor by user as:-U Somebody
-u:monitor by user as:-U Somebody
-p:monitor PIDs as:-pn1-pn2 ... or-pn1, N2 [,...]
-s:secure mode operation
-s:cumulative Time Mode Toggle
-v:version
-m:detect Memory Units
However, you can use interactive commands when the text is displayed in full screen, such as uppercase M to make the process appear sorted by memory usage, and by CPU using the uppercase p.
You can save the current settings in the configuration file by using the upper case w, which is generally ~/.TOPRC, so that the next launch of the top command is displayed in a set order.
Man top wrote
W:write_the_configuration_file
This would save all of your options and toggles plus the current
Display mode and delay time. By issuing this command just
Before quitting top, you'll be being able restart later in exactly
That's same state.
1:toggle_single/separate_cpu_states-On/off
This command affects the "T ' command ' s CPU states portion is
Shown. Although this toggle exists primarily to serve mas-
Sively-parallel SMP machines, it isn't restricted to solely SMP
Environments.
Sorting of Task window
For compatibility, this top supports most of the former top sort
Keys. Since This was primarily a service to former top users, these
Commands does not appear on any to help screen.
Command sorted field supported
A start Time (non-display) No
M%MEM Yes
N PID Yes
P%cpu Yes
T time+ Yes
Below is a sample of a ~/.TOPRC file. This file is a little complicated, not carefully read.
Text Code
Rcfile for "Top with Windows" # shameless Braggin '
Id:a, mode_altscr=0, mode_irixps=1, delay_time=3.000, curwin=0
Def Fieldscur=aehioqtwknmbcdfgjplrsuvyzx
winflags=62777, sortindx=, maxtasks=0
summclr=1, msgsclr=1, headclr=3, taskclr=1
Job FIELDSCUR=ABCEFGJLRSTUVYZMKNHIWOPQDX
winflags=62777, sortindx=0, maxtasks=0
summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem Fieldscur=anopqrstuvbcdefgjlmyzwhikx
winflags=62777, sortindx=, maxtasks=0
Summclr=5, msgsclr=5, headclr=4, taskclr=5
USR FIELDSCUR=ABDECGFHIJLOPQRSTUVYZMKNWX
winflags=62777, sortindx=4, maxtasks=0
Summclr=3, msgsclr=3, headclr=2, taskclr=3
How do I sort by memory usage (or CPU usage sort) After the top command is started under Linux?