Skip to content

Instantly share code, notes, and snippets.

@mouyong
Forked from stiekel/ksort.js
Created June 11, 2017 11:59
Show Gist options
  • Save mouyong/a8c03726ea66e28efec351d36cc6ef77 to your computer and use it in GitHub Desktop.
Save mouyong/a8c03726ea66e28efec351d36cc6ef77 to your computer and use it in GitHub Desktop.

Revisions

  1. @stiekel stiekel created this gist Apr 28, 2015.
    10 changes: 10 additions & 0 deletions ksort.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    function ksort(obj){
    var keys = Object.keys(obj).sort()
    , sortedObj = {};

    for(var i in keys) {
    sortedObj[keys[i]] = obj[keys[i]];
    }

    return sortedObj;
    }