UNPKG

293 BJavaScriptView Raw
1'use strict'
2
3const lodash = require('lodash')
4
5function sort (obj) {
6 if (!lodash.isPlainObject(obj)) {
7 return obj
8 }
9
10 const sortedObj = {}
11 const keys = Object.keys(obj).sort()
12
13 keys.forEach(key => {
14 sortedObj[key] = obj[key]
15 })
16
17 return sortedObj
18}
19
20module.exports = sort