diff --git a/top/top.1 b/top/top.1 index 9f86cb0c..bce1e00f 100644 --- a/top/top.1 +++ b/top/top.1 @@ -306,6 +306,9 @@ produce before ending. \-\fBo\fR :\fI Override-sort-field\fR as:\fB\ \ \-o fieldname \fR Specifies the name of the field on which tasks will be sorted, independent of what is reflected in the configuration file. +You can prepend a '+' or '\-' to the field name to also override the sort direction. +A leading '+' will force sorting high to low, whereas a '\-' will ensure a low to high +ordering. This option exists primarily to support automated/scripted batch mode operation. diff --git a/top/top.c b/top/top.c index e1715d7b..c17d93fc 100644 --- a/top/top.c +++ b/top/top.c @@ -3291,6 +3291,8 @@ static void parse_args (char **args) { if (cp[1]) cp++; else if (*args) cp = *args++; else error_exit(fmtmk(N_fmt(MISSING_args_fmt), ch)); + if (*cp == '+') { SETw(Curwin, Qsrt_NORMAL); ++cp; } + else if (*cp == '-') { OFFw(Curwin, Qsrt_NORMAL); ++cp; } for (i = 0; i < P_MAXPFLGS; i++) if (!STRCMP(cp, N_col(i))) break; if (i == P_MAXPFLGS)