index.js
function sortArgs(app, argv, options) {
  options = options || [];

  var first = options.first || [];
  var last = options.last || [];
  var cliKeys = [];

  if (app.cli && app.cli.keys) {
    cliKeys = app.cli.keys;
  }

  var keys = utils.union(first, cliKeys, Object.keys(argv));
  keys = utils.diff(keys, last);
  keys = utils.union(keys, last);

  var len = keys.length;
  var idx = -1;
  var res = {};

  while (++idx < len) {
    var key = keys[idx];
    if (argv.hasOwnProperty(key)) {
      res[key] = argv[key];
    }
  }
  return res;
}
function sortArgs(app, argv, options) {
  options = options || [];

  var first = options.first || [];
  var last = options.last || [];
  var cliKeys = [];

  if (app.cli && app.cli.keys) {
    cliKeys = app.cli.keys;
  }

  var keys = utils.union(first, cliKeys, Object.keys(argv));
  keys = utils.diff(keys, last);
  keys = utils.union(keys, last);

  var len = keys.length;
  var idx = -1;
  var res = {};

  while (++idx < len) {
    var key = keys[idx];
    if (argv.hasOwnProperty(key)) {
      res[key] = argv[key];
    }
  }
  return res;
}
function sortArgs ( app , argv , options ) { options = options || [ ] ; var first = options . first || [ ] ; var last = options . last || [ ] ; var cliKeys = [ ] ; if ( app . cli && app . cli . keys ) { cliKeys = app . cli . keys ; } var keys = utils . union ( first , cliKeys , Object . keys ( argv ) ) ; keys = utils . diff ( keys , last ) ; keys = utils . union ( keys , last ) ; var len = keys . length ; var idx = - 1 ; var res = { } ; while ( ++ idx < len ) { var key = keys [ idx ] ; if ( argv . hasOwnProperty ( key ) ) { res [ key ] = argv [ key ] ; } } return res ; }
Sort arguments so that `app.cli.process` executes commands
in the order specified.

@param {Object} `app` Application instance
@param {Object} `argv` The expanded argv object
@param {Object} `options`
@param {Array} `options.first` The keys to run first.
@param {Array} `options.last` The keys to run last.
@return {Object} Returns the `argv` object with sorted keys.
Sort arguments so that app . cli . process executes commands in the order specified .