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.
JavaScript ksort
function ksort(obj){
var keys = Object.keys(obj).sort()
, sortedObj = {};
for(var i in keys) {
sortedObj[keys[i]] = obj[keys[i]];
}
return sortedObj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment