I am trying to sort a hashtable (originally called "resultVal") alphabetically in javascript.
// initializing an array with all the keys. //
var keys = [];
// populating it with all the keys in the hashtable. //
for (var key in resultVal) {
if (resultVal.hasOwnProperty(key)) {
keys.push(key);
}
}
// Alphabetically sorting the array populated with hash table keys. //
keys.sort();
var temp = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = resultVal[key];
if (key != "") {
temp[key].push(value);
}
}
My issue is with the last statement :-
temp[key].push(value);
What I am doing is, sort the keys alphabetically and re-feed the key and its respective values into a temp hashtable..."temp".
The push statement isn't being recognized. can anyone help?