UNPKG

compound-ex4

Version:

Compound-ex4 - MVC framework for NodeJS (ExpressJs 4 version), fork compoundjs(https://github.com/1602/compound)

18 lines (15 loc) 428 B
#!/usr/bin/env node var cli = require('cli'); var options = cli.parse({ numeric: ['n', 'Compare using a numeric sort'], reverse: ['r', 'Reverse the results'] }); cli.withStdinLines(function (lines, newline) { lines.sort(!options.numeric ? null : function (a, b) { return parseInt(a) > parseInt(b); }); if (options.reverse) { lines.reverse(); } this.output(lines.join(newline)); });