Top command is used often to check linux system loading , or find which processes are slowing down the system, by default top sorts command by %cpu , we can use one of below methods to let top sort processes by memory or swap

1.Using option “-o” of command top to Specifies the name of the field on which tasks will be sorted

top -o %MEM  # sort by memory


top -o SWAP # sort by swap
  1. Use top’s fields managing interactive command “f” or “F”

a, issue “top” command directly

b, hit key “f” or “F”

c, then you can follow the instruction to toggle and set fields