Interactive programs are a bad source of input to scripts. I strongly advice you to consider ps(1) utility; it has a lot of different process selection options, can output arbitrary column set with fine-tuned field formatting, can do sorting.