[HRPM] Sorting and array of lines returned from 'ps'

Matt Shivers mshivers11 at home.com
Sat Nov 18 15:04:26 CST 2000


Hello all,

I have an interesting sorting problem. I need to sort an array of lines returned from the 'ps' command. Each line contains the following information:

PID, USER, UID, TIME, %CPU, %MEM, CMD

I need to sort the array based on the different fields within each line. For instance, sort based on USER, then sort based on TIME, etc... depending on how the user wants the information displayed.

I looked at the built in sorting options available in 'ps', but the 'ps' sort option doesn't contain all the fields I need to sort on.

I also looked at the sort function built into Perl, but it looks to be a simple sort based on the entire element in the array. 

Has anyone sorted in this fashion before? 

Thanks,

Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/norfolk-pm/attachments/20001118/f90e457e/attachment.htm


More information about the Norfolk-pm mailing list