0

I have an array in php, I took it in javascript using this variable

 <script>

   var myArray = <?php echo json_encode($id); ?>;

 </script>

here is a sample data loaded in the javascript variable

 var myArray = [{"product":"AMALFI COAST BISTRO WALKING","prod_id":179,"thumb":"/wp\/tangtours\/wp-content\/uploads\/2013\/04\/AMCWB_fi-148x106.jpg"},{"product":"ARGENTINA BIKING","prod_id":186,"thumb":"/wp\/tangtours\/wp-content\/uploads\/2013\/04\/ARGEB_fi-148x106.jpg"},{"product":"CHINA PRIVATE","prod_id":188,"thumb":"/wp\/tangtours\/wp-content\/uploads\/2013\/04\/CHNR2B_fi-148x106.jpg"},{"product":"BORDEAUX TO DORDOGNE BIKING","prod_id":191,"thumb":"/wp\/tangtours\/wp-content\/uploads\/2013\/04\/BDOBS_fi-148x106.jpg"},{"product":"AMERICAN WEST COAST BESPOKE","prod_id":198,"thumb":"/wp\/tangtours\/wp-content\/uploads\/2013\/04\/AWCB1_fi-148x106.jpg"},{"product":"BHUTAN PRIVATE","prod_id":195,"thumb":"/wp\/tangtours\/wp-content\/uploads\/2013\/04\/BTNR2B_fi-148x106.jpg"}];

All I have to do is to sort this content using jquery or javascript by product, prod_id and thumb.

is there any simple way to sort this content and print them in a div in Ascending and descending order using jquery or javascript?

this is a sample site http://www.butterfield.com/tripfinder/ of what I really need. please use sort by options on the right top, they used dojo to do it, and I am not much familiar with dojo anyway. thank you.

user1845827
  • 319
  • 2
  • 3
  • 8
  • 1
    Did you try searching? http://stackoverflow.com/questions/5503900/how-to-sort-an-array-of-objects-with-jquery-or-javascript?rq=1 (amongst others) – nnnnnn May 13 '13 at 12:39
  • also see here http://stackoverflow.com/questions/7104024/jquery-sorting-an-array-of-objects – PSR May 13 '13 at 12:39
  • Yeah I tried those except one, now I'll try the left one. – user1845827 May 13 '13 at 12:45
  • Is it possible to print value in a div using these lines? – user1845827 May 13 '13 at 12:51

0 Answers0