Plato on Github
Report Home
node_modules/cli/examples/sort.js
Maintainability
79.61
Lines of code
16
Difficulty
11.59
Estimated Errors
0.13
Function weight
By Complexity
By SLOC
//#!/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)); });