(Video materials in preparation)
msort : In-Memory Sort
Usage : msort key=<key> <file>
Options : -e
-s<c>
-p<n>
--stable
Version : Tue Jan 9 09:02:34 JST 2024
Edition : 5
Sorts a file on specfied key by <key>. <key> designates the field
position as fllows:
single field 2 the 2nd field
NF the last field
NF-1 the field just before the last field
contiguous fields 2/4 from the 2nd field to the 4th field
4/2 from the 4th field to the 2nd field
NF-3/NF from NF-3 field to the NF field
combination 2@NF the 2nd field and the NF field
There is no limit on the length of the key field or on the number
of key fields. The key field can also contain multi-byte characters
such as Japanese.
If you specify "r" as sort method after the field position, the
values will be sorted in descending order. If you specify "n" as
sort method after the field position, that field's values will be
sorted as numbers. If you specify "nr" as sort method after the
field, the values will be sorted in descending order as numbers. If
you specify sort method before or after the "/", you must use the
same sort method for both fields.
2n/5n OK
2n/5nr Error
2n/5r Error
When you specify "e" as sort method or specify -e ootion and no
method, characters in the field are replaced as follows and compared
as string:
_ ==> 0x20 (space)
\0 ==> 0x00 (null)
\t ==> 0x09 (tab stop)
\n ==> 0x0a (new line)
\r ==> 0x0d (carrige return)
\_ ==> 0x5f (underscore)
\\ ==> 0x5c (back slash)
If the file name is omitted or if it is specified as "-" then the
command will read from standard input.
If you specify the -p<n> option, the command will run in <n>
parallel processes. There is no limit to the number of parallel
processes you can specify, but if you specify more processes
than there are cores available on your CPU then performance
will be degraded. If you are sorting less than 10,000 lines,
even if you specify the -p<n> option it will only run in single
process.
--stable is prepared for compatibility with isort, and ignored by
this command.
msort uses the merge sort algorithm, so there is no danger that the
processing time will be extremely long no matter what state the
input data is in.
msort is an in-memory sort, so it will use at a maximum three times
the memory as the size of the file being sorted.