title: How to fetch list of running processes on a system and sort them by various parameters
body: <p>I use htop to view information about the processes currently running in my osx machine, also to sort them by CPU, memory usage, etc.</p>
  
  <p>Is there any way to fetch the output of htop programatically in Ruby?. Also I would like to be able to use the API to sort the processes using various parameters like CPU, memory usage, etc.</p>
  
  <p>I can do <code>IO.popen('ps -a')</code> and parse the output, but want to know if there is a better way than directly parsing the output of a system command run programmatically.</p>