SyntaxFix
Write A Post
Hire A Developer
Questions
Get the keys in the first for loop, sort it, use the sorted result in the 2nd for loop.
for
var a = new Array(); a['b'] = 1; a['z'] = 1; a['a'] = 1; var b = []; for (k in a) b.push(k); b.sort(); for (var i = 0; i < b.length; ++i) alert(b[i]);