Sort object properties by key - Node.js Object

Node.js examples for Object:Object Operation

Description

Sort object properties by key

Demo Code


Object.sortByKeys = function (obj) {
    var that = obj;
    return Object.keys(obj).sort().reduce(function (result, key) {
        result[key] = that[key];//from ww w .  j a  v a2  s . c  o  m
        return result;
    }, {});
}

Related Tutorials