Sort according to the values of the specified fields at f= within each record (in default ascending order by character string). Note that this does not change the sequence of field names.
mfsort f= [-r] [-n] [i=] [o=] [-nfn] [-nfno] [-x] [--help] [--version]
f= Specify multiple fields where data items are sorted. The result remains the same when one field is defined. -n Arrange in numerical order. -r Arrange in reverse order.
Arrange the values in v1,v2,v3 in ascending order for each record, and output the data items in sequential order corresponding to fields v1,v2,v3.
$ more dat1.csv id,v1,v2,v3 1,b,a,c 2,a,b,a 3,b,,e $ mfsort f=v* i=dat1.csv o=rsl1.csv #END# kgfsort f=v* i=dat1.csv o=rsl1.csv $ more rsl1.csv id,v1,v2,v3 1,a,b,c 2,a,a,b 3,,b,e
Add -r to arrange in descending order.
$ mfsort f=v* -r i=dat1.csv o=rsl2.csv #END# kgfsort -r f=v* i=dat1.csv o=rsl2.csv $ more rsl2.csv id,v1,v2,v3 1,c,b,a 2,b,a,a 3,e,b,