This command sort series of vectors in column. The vector in the fields shown in Table 3.45 shows multiple character strings separated by space delimiter. Table 3.45 - 3.45 highlight examples sorting vectors.
In Table 3.45, character strings are arranged in ascending order by default. The character strings can be sorted in numerical ascending order by attaching % after the item name followed by n (see Table 3.45), and in reverse order by specifying r after an item name (Table 3.45).
Table 3.45: Input data in.csv |
||||||||||
no items 1 2 1 13 2 4 5 2 5 3 112 14 4 5 31 |
no |
items |
1 |
1 13 2 |
2 |
2 4 5 5 |
3 |
112 14 |
4 |
31 5 |
no |
items |
1 |
1 2 13 |
2 |
2 4 5 5 |
3 |
14 112 |
4 |
5 31 |
no |
items |
1 |
13 2 |
2 |
5 5 4 2 |
3 |
112 14 |
4 |
31 5 |
mvsort vf= [i=] [o=] [delim=] [-nfn] [-nfno] [-x] [--help] [--version]
vf= Specify the field name(s) of vectors for sorting. Multiple fields can be specified. Add n after % after field name to sort in ascending numerical order. Add r after % after field name to sort in reverse order. Add both n and r to sort in descending numerical order.
Sort item1 data series in ascending order and item2 in numerical ascending order.
$ more dat1.csv items1,items2 b a c,10 2 c c,2 5 3 e a a,1 $ mvsort vf=items1%r,items2%n i=dat1.csv o=rsl1.csv #END# kgvsort i=dat1.csv o=rsl1.csv vf=items1%r,items2%n $ more rsl1.csv items1,items2 c b a,2 10 c c,2 3 5 e a a,1