UNPKG

428 BJavaScriptView Raw
1#!/usr/bin/env node
2
3var cli = require('cli');
4
5var options = cli.parse({
6 numeric: ['n', 'Compare using a numeric sort'],
7 reverse: ['r', 'Reverse the results']
8});
9
10cli.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