Sort Multidimentional Array

Closed Forum
Locked
rangsit
Guest

Sort Multidimentional Array

Post by rangsit »

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.
User avatar
Daifne
Moderator
Posts: 123071
Joined: July 31st, 2005, 9:17 pm
Location: Where the Waters Meet, Wisconsin

Post by Daifne »

Moving to Miscellaneous Support. But we probably still won't do your homework for you.
old zmanzero
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old zmanzero »

rangsit, will you post the grade you get on the test? the curious want to know. i really don't know the answer or i would post it.
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Post by trolly »

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.
Locked