JavaScript How to sort multidimensional array in javascript sort multidimensional array php,sort multidimensional array javascript,sort multidimensional

I have an array as follows

var arry = [ [1, "Convention Hall", "Mumbai", 10, "XYZ Company"], 
             [2, "Auditorium", "Delhi", 10, "ABC Company"], 
             [3, "CenterHall", "Bangalore", 10, "ZZZ Company"],
            ....
            ]

I want to sort the array alphabetically based on the third item of array i.e arry[n][2]

How to do this.

Answer:1

http://jsfiddle.net/VPrAr/

enter image description here

You can use the arry.sort(). The default is alphanumeric and ascending.

So it would be:

var arry = [ [1, "Convention Hall", "Dangalore", 10, "XYZ Company"], 
             [2, "Auditorium", "Belhi", 10, "ABC Company"], 
             [3, "CenterHall", "Aumbai", 10, "ZZZ Company"],
            ];
var x =arry.sort(function(a,b){ return a[2] > b[2] ? 1 : -1; });
alert(x);
Answer:2

Use a sort function for example:

arry.sort(function(a,b){
   return a[2] > b[2] ? 1 : -1;
});
Answer:3

When you serialise a form using jQuery.serialize(), the method will serialise the form fields and its values so you can submit to the server. Is there a method/function that would do the same with a ...

When you serialise a form using jQuery.serialize(), the method will serialise the form fields and its values so you can submit to the server. Is there a method/function that would do the same with a ...

  1. deserialize javascript object c#
  2. deserialize javascript object
  3. serialise javascript object
  4. javascript serialise object to json
  5. serialize javascript object
  6. serialize javascript object to json
  7. serialize javascript object with functions
  8. serialize javascript object to query string
  9. serializable javascript object
  10. serialize javascript object to string
  11. serialize javascript object to xml
  12. serialize javascript object to array
  13. js serialise object
  14. javascript serialize object for post
  15. javascript serialize object c#
  16. javascript serialize object to url string
  17. javascript serialize object to form data
  18. javascript serialize object to json c#
  19. javascript serialize object to file
  20. javascript serialize object to byte array

A really simple program, but I am not sure why its not getting executed. Here's my HTML file :- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-...

A really simple program, but I am not sure why its not getting executed. Here's my HTML file :- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-...

  1. alert not working in document.ready

I have to build a program for the employees of my company to declare days of work, vacation, days of illness etc.. My idea was to use fullcalendar drag and drop function to make something nice. Only ...

I have to build a program for the employees of my company to declare days of work, vacation, days of illness etc.. My idea was to use fullcalendar drag and drop function to make something nice. Only ...

  1. extract event from splunk
  2. extract event logs from windows
  3. extract data from event viewer
  4. extract logs from event viewer
  5. extract json from event splunk
  6. extract certificate from event log
  7. extract time from event splunk
  8. extract event logs from sap

click not working after i clear and append the html inside a div using jquery. Here is the html code <div id="divMain"> </div> <input id="btn" type="button" value="Clear&Add"/> ...

click not working after i clear and append the html inside a div using jquery. Here is the html code <div id="divMain"> </div> <input id="btn" type="button" value="Clear&Add"/> ...

  1. click not working after append
  2. click not working after ajax
  3. click function not working after append
  4. click function not working after ajax
  5. click event not working after append
  6. click function not working after ajax call
  7. jquery click not working after append
  8. jquery click not working after ajax
  9. right click not working after effects
  10. ng-click not working after append
  11. left click not working after effects
  12. button click not working after postback
  13. jquery click not working after load
  14. jquery click not working after html
  15. ng-click not working after compile
  16. ng-click not working after ng-blur
  17. button click not working after response.end
  18. button click not working after print
  19. right click not working after update