173d5214db
Use NULL in format_array to indicate that the print function shall be used also for sorting. Change sr_nop() to NULL for all fields which don't use pr_nop() for printing. Before the commit (note that '--sort label' has no effect: the rows are not sorted according to label field): $ ps -A -o command,label --sort label | grep /lib/systemd /lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0 /lib/systemd/systemd-udevd system_u:system_r:udev_t:s0-s0:c0.c1023 /lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0 /lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0 /lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0 /lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0 /lib/systemd/systemd --user user_u:user_r:user_t:s0 /lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023 grep /lib/systemd user_u:user_r:user_t:s0 After the commit, '--sort label' works and the output is sorted: $ ps -A -o command,label --sort label | grep /lib/systemd /lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023 /lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0 /lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0 /lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0 /lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0 /lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0 /lib/systemd/systemd-udevd system_u:system_r:udev_t:s0-s0:c0.c1023 /lib/systemd/systemd --user user_u:user_r:user_t:s0 grep /lib/systemd user_u:user_r:user_t:s0 Signed-off-by: Topi Miettinen <toiwoton@gmail.com>