Javascript Object Sorting by Keys

> var input = { ‘z’:’zzz’, ‘a’:’aaa’,’x’:’xxx’,’b’:’bbb’}
> console.log(input)
Object {z: “zzz”, a: “aaa”, x: “xxx”, b: “bbb”}

> var output = _.object(_.sortBy(_.pairs(refData),function(o){return o[0]}));
> console.log(output)
Object {a: “aaa”, b: “bbb”, x: “xxx”, z: “zzz”}

Leave a Reply

Your email address will not be published. Required fields are marked *

− 1 = 7