Hi there, i got a problem about how to sort a multidimentional array. The following is the example of multidimentaional array.
var hospital = [["HospitalA",numA,"James Smith"],
["HospitalB",numB,"Peter Smith"],
["HospitalB",numB,"Jim Thompson"],
["HospitalC",numC,"Richard Scott"]]
and var numA=0.21, numB=3.21, numC=2.41, numD=4.01
I wanna sort the all numbers which is index 1 of each line, hospital[i][1]. I really need help. Thx in advance.
Sort Multidimentional Array
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
- trolly
- Moderator
- Posts: 39851
- Joined: August 22nd, 2005, 7:25 am
Exactly the same way you sort "normal" arrays, just swapping arrays instead of numbers here.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.