I have 3 arrays :
array 1 is "Name" John, Jim, Jack, Jill
array 2 is "Age" 25, 30, 31, 22
array 3 is "Gender" Male, Male, Male, Female
I have these all listed in a table with a sortable header. Now the sort works fine, it sorts by the "Name" column for example. How can i also make it sort the "Age" and "Gender" arrays to keep them correct. I need to sort all 3 simultaneously.
_nameArray.sort(function(a, b){
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
})
Hope it is explained well enough.
No the structure can not be changed, the way things are it has to be 3 arrays, not one and just sort by the field in the array.
See Question&Answers more detail:os