index.js 356 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var sortKeys = require('sort-keys');
  3. /**
  4. * Sort object keys by length
  5. *
  6. * @param obj
  7. * @api public
  8. */
  9. module.exports.desc = function (obj) {
  10. return sortKeys(obj, function (a, b) {
  11. return b.length - a.length;
  12. });
  13. }
  14. module.exports.asc = function (obj) {
  15. return sortKeys(obj, function (a, b) {
  16. return a.length - b.length;
  17. });
  18. }