1 |
|
2 |
|
3 | var cli = require('cli');
|
4 |
|
5 | var options = cli.parse({
|
6 | numeric: ['n', 'Compare using a numeric sort'],
|
7 | reverse: ['r', 'Reverse the results']
|
8 | });
|
9 |
|
10 | cli.withStdinLines(function (lines, newline) {
|
11 | lines.sort(!options.numeric ? null : function (a, b) {
|
12 | return parseInt(a) > parseInt(b);
|
13 | });
|
14 | if (options.reverse) {
|
15 | lines.reverse();
|
16 | }
|
17 | this.output(lines.join(newline));
|
18 | }); |
\ | No newline at end of file |