R
RC
I have simple hashtable object
function myHashTable(key, value) {
this.key = key;
this.value = value;
}
var myObjectArray = new Array(5);
myObjectArray[0] = new myHashTable(1, "2006-06-07");
myObjectArray[1] = new myHashTable(2, "2005-04-10");
.....
Now my question is how do I sort the value, not the key
in myObjectArray?
I did
myObjectArray.sort(myHashTable);
But the output result are NOT correct.
The correct result after sort should be:
myObjectArray[0].key is 2, myObjectArray.value is 2005-04-10
myObjectArray[1].key is 1, myObjectArray.value is 2006-06-07
Thank Q very much in advance!
function myHashTable(key, value) {
this.key = key;
this.value = value;
}
var myObjectArray = new Array(5);
myObjectArray[0] = new myHashTable(1, "2006-06-07");
myObjectArray[1] = new myHashTable(2, "2005-04-10");
.....
Now my question is how do I sort the value, not the key
in myObjectArray?
I did
myObjectArray.sort(myHashTable);
But the output result are NOT correct.
The correct result after sort should be:
myObjectArray[0].key is 2, myObjectArray.value is 2005-04-10
myObjectArray[1].key is 1, myObjectArray.value is 2006-06-07
Thank Q very much in advance!