iam designing hotel selector block customer can choose hotels based on available hotels available @ day , on location, have fetch available hotels destination , date , showing hotels individual grid (box) of col-md-4. want give customers button sort hotels based on hotel type (a numerical star value) , display results ther sort prams.
my ajax code fetch hotels :
function hotel_selector(id,location,date){ jquery(document).ready(function($){ $('.loader').show(); $('#hotel_details').empty(); $.ajax({ type:'post', url:'admin/new_admin/hotel_selector.php', data: 'location='+ location +'&date='+date, success: function(value){ var value1 = value; value1.sort(function(a, b) { return parsefloat(a.hotel_type) - parsefloat(b.hotel_type); }); var data = json.parse(value1); alert(value1); $('#show_hotel').modal('show'); var hotel_at = location.substr(0,1).touppercase()+location.substr(1); $("#hotel_at").html(hotel_at); $("#hotel_on").html(date); var = 0; var b = 0; var c = 0; var status = 0; var html=''; for(a=0;a<data.length;a++){ html += '<div class="col-md-4 col-xs-6">'; html += '<div class="panel panel-primary">'; html += '<div class="panel-heading">'; html += data[a].hotel_name; html += '</div>'; html += '<div class="panel-body" style="height: 350px;">'; html += '<div class="col-md-12">'; html += '<img src="hotel_images/thumb/'+data[a].hotel_img+'" class="img-responsive img-thumbnail"/>'; html += '</div>'; html += '<div class="col-md-12 padding-top-10 text-smaller">'; var hotel_id = data[a].hotel_id; for(b=0;b<data[a].rooms.length;b++) { if(data[a].rooms[b].hotel_id == hotel_id){ var roomtype_id = data[a].rooms[b].roomtype_id; for(c=0;c<data[a].rooms[b].inventory.length;c++){ if(data[a].rooms[b].inventory[c].hotel_id == hotel_id && data[a].rooms[b].inventory[c].roomtype_id == roomtype_id && data[a].rooms[b].inventory[c].cost != 0 && data[a].rooms[b].inventory[c].available_rooms != 0){ html += '<label class="left"><input type="radio" autocomplete="off" value="'+data[a].rooms[b].roomtype_id+'" name="room_type'+id+'">'+data[a].rooms[b].type_name+' (rs. '+data[a].rooms[b].inventory[c].cost+') </label><br />'; var status = 1; } else{ html += '<label class="left"><input type="radio" autocomplete="off" value="'+data[a].rooms[b].roomtype_id+'" name="room_type'+id+'" disabled>'+data[a].rooms[b].type_name+' <font size="0.1px" class="text-danger">(sold)</font> </label><br />'; var status = 1; } } } } html += '</div>'; html += '</div>'; html += '<div class="panel-footer">'; if(c > 0){ html += '<a href="#" class="btn btn-success btn-block" onclick="changehotel(\''+id+'\',\''+data[a].hotel_id+'\', \''+data[a].hotel_name+'\', \''+data[a].hotel_img+'\', \''+data[a].hotel_location+'\', \''+data[a].hotel_type+'\')" data-dismiss="modal" aria-hidden="true">add</a>'; } else{ html += '<a href="#" class="btn btn-success btn-block" disabled>add</a>'; } html += '</div>'; html += '</div>'; html += '</div>'; } $('#hotel_details').append(html); $(".loader").fadeout("slow"); } }); }); }
my json response iam getting is:
[{"hotel_id":"1","hotel_name":"white coral","hotel_location":"portblair","hotel_type":"3","hotel_description":"<div id=\"ta_cdsratingsonlynarrow624\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"muuhotm4f\" class=\"ta_links xpatam\">\r\n<li id=\"mjbi7wet8\" class=\"vdc6wqg\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.com\/\"><img src=\"https:\/\/www.tripadvisor.com\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=7112033&border=false&uniq=624&lang=en_us&display_version=2\"><\/script>\r\n","hotel_img":"white coral.jpg","visibility":"visible","rooms":[{"roomtype_id":"1","hotel_id":"1","type_name":"standard","meal_plan":"map","description":"bed: queen occupancy: 2 persons size: 180 sqft view: lakeview\/mountain view, ensuit bathroom: cable t.v: coffee\/tea maker: free internet: breakfast included: balcony: matress: room service: hot running water: glass window: ","img":"standard.jpg","inventory":[{"inventory_id":"175","hotel_id":"1","roomtype_id":"1","capacity_id":"0","date_id":"211","cost":"2600","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"400","em":"1000","wem":"800"}]}]},{"hotel_id":"2","hotel_name":"hotel velocity","hotel_location":"portblair","hotel_type":"2","hotel_description":"<div id=\"ta_cdsratingsonlynarrow562\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"cknqwjp\" class=\"ta_links jqijv3tc\">\r\n<li id=\"gkt7xdwvdd4j\" class=\"dqso1ad\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=5778821&border=false&uniq=562&lang=en_in&display_version=2%22\"><\/script>","hotel_img":"hotel velocity.jpg","visibility":"visible","rooms":[{"roomtype_id":"2","hotel_id":"2","type_name":"standard","meal_plan":"cp","description":"room size 13 \u2013 19,5 m2, 1 or 2 beds 90 \u2013 180 cm, bathroom shower or bath ","img":"standard.jpg","inventory":[{"inventory_id":"1371","hotel_id":"2","roomtype_id":"2","capacity_id":"0","date_id":"211","cost":"2000","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"800","wem":"600"}]},{"roomtype_id":"3","hotel_id":"2","type_name":"deluxe","meal_plan":"cp","description":"room size 17,5 \u2013 19,5 m2, 1 or 2 beds 90-180 cm, complimentary bottled water, pillows, bed cover , decorative pillows, bathroom shower or bath designer bathroom amenities","img":"deluxe.jpg","inventory":[{"inventory_id":"1969","hotel_id":"2","roomtype_id":"3","capacity_id":"0","date_id":"211","cost":"2200","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"800","wem":"600"}]},{"roomtype_id":"4","hotel_id":"2","type_name":"family(3 bed)","meal_plan":"cp","description":"room size 37 \u2013 39 m2, 1 bed 200 cm, bathrobe , slippers,coffee , tea making facilities, folding sofa, designer bathroom amenities","img":"family(3 bed).jpg","inventory":[{"inventory_id":"2567","hotel_id":"2","roomtype_id":"4","capacity_id":"0","date_id":"211","cost":"3000","available_rooms":"2","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"800","wem":"600"}]}]},{"hotel_id":"3","hotel_name":"suncity resort ","hotel_location":"portblair","hotel_type":"4","hotel_description":"<div id=\"ta_cdsratingsonlynarrow61\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"i44ysiwr2l\" class=\"ta_links i6yn53nu3q\">\r\n<li id=\"ixnbv3\" class=\"ced4dj6k\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=1892754&border=false&uniq=61&lang=en_in&display_version=2\"><\/script>","hotel_img":"suncity resort .jpg","visibility":"visible","rooms":[{"roomtype_id":"5","hotel_id":"3","type_name":"deluxe","meal_plan":"cp","description":" ","img":"","inventory":[{"inventory_id":"3165","hotel_id":"3","roomtype_id":"5","capacity_id":"0","date_id":"211","cost":"6000","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"600","em":"2000","wem":"1500"}]}]},{"hotel_id":"4","hotel_name":"hotel marine view","hotel_location":"portblair","hotel_type":"2","hotel_description":"<div id=\"ta_cdsratingsonlynarrow694\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"ziqnmrregz3w\" class=\"ta_links ec6urdux\">\r\n<li id=\"kdzw1taoh\" class=\"unfkcbw5i\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=1734210&border=false&uniq=694&lang=en_in&display_version=2\"><\/script>","hotel_img":"hotel marine view.jpg","visibility":"visible","rooms":[{"roomtype_id":"6","hotel_id":"4","type_name":"standard","meal_plan":"cp","description":" ","img":"","inventory":[{"inventory_id":"4357","hotel_id":"4","roomtype_id":"6","capacity_id":"0","date_id":"211","cost":"2000","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"400","em":"800","wem":"600"}]},{"roomtype_id":"7","hotel_id":"4","type_name":"standard (triple)","meal_plan":"cp","description":" ","img":"","inventory":[{"inventory_id":"4953","hotel_id":"4","roomtype_id":"7","capacity_id":"0","date_id":"211","cost":"2700","available_rooms":"3","booked_rooms":"0","blocked_rooms":"0","meal":"400","em":"800","wem":"600"}]}]},{"hotel_id":"5","hotel_name":"chaukhat (bed & breakfast)","hotel_location":"portblair","hotel_type":"3","hotel_description":"<div id=\"ta_cdsratingsonlynarrow956\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"uuyd3fadt51v\" class=\"ta_links fl5ibx9w\">\r\n<li id=\"m3g7wfwam\" class=\"a76s7cwqqpe\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=4893817&border=false&uniq=956&lang=en_in&display_version=2\"><\/script>\r\n","hotel_img":"chaukhat (bed & breakfast).jpg","visibility":"visible","rooms":[{"roomtype_id":"8","hotel_id":"5","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"5549","hotel_id":"5","roomtype_id":"8","capacity_id":"0","date_id":"211","cost":"2800","available_rooms":"6","booked_rooms":"0","blocked_rooms":"0","meal":"400","em":"1000","wem":"800"}]}]},{"hotel_id":"6","hotel_name":"peerless sarovar portico","hotel_location":"portblair","hotel_type":"4","hotel_description":"<div id=\"ta_cdsratingsonlynarrow695\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"fddyifmdu5\" class=\"ta_links aa6rtqw\">\r\n<li id=\"wnolhi\" class=\"x7ajisr\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=499988&border=false&uniq=695&lang=en_in&display_version=2\"><\/script>","hotel_img":"peerless sarovar portico.jpg","visibility":"visible","rooms":[{"roomtype_id":"9","hotel_id":"6","type_name":"deluxe","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"6145","hotel_id":"6","roomtype_id":"9","capacity_id":"0","date_id":"211","cost":"6500","available_rooms":"8","booked_rooms":"0","blocked_rooms":"0","meal":"600","em":"2000","wem":"1500"}]},{"roomtype_id":"125","hotel_id":"6","type_name":"sea view","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"11957","hotel_id":"6","roomtype_id":"125","capacity_id":"0","date_id":"211","cost":"11000","available_rooms":"0","booked_rooms":"0","blocked_rooms":"0","meal":"600","em":"2000","wem":"1500"}]},{"roomtype_id":"126","hotel_id":"6","type_name":"cottage","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"12548","hotel_id":"6","roomtype_id":"126","capacity_id":"0","date_id":"211","cost":"12000","available_rooms":"0","booked_rooms":"0","blocked_rooms":"0","meal":"600","em":"2000","wem":"1500"}]}]},{"hotel_id":"7","hotel_name":"hotel ritz","hotel_location":"portblair","hotel_type":"1","hotel_description":"no reviews\r\n","hotel_img":"hotel ritz.jpg","visibility":"visible","rooms":[{"roomtype_id":"10","hotel_id":"7","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"6741","hotel_id":"7","roomtype_id":"10","capacity_id":"0","date_id":"211","cost":"1600","available_rooms":"8","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"600","wem":"400"}]},{"roomtype_id":"11","hotel_id":"7","type_name":"four bed","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"7336","hotel_id":"7","roomtype_id":"11","capacity_id":"0","date_id":"211","cost":"3000","available_rooms":"3","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"600","wem":"400"}]}]},{"hotel_id":"8","hotel_name":"pearl harbour","hotel_location":"portblair","hotel_type":"0","hotel_description":"<div id=\"ta_linkingwidgetredesign54\" class=\"ta_linkingwidgetredesign\">\r\n<ul id=\"xoggovauur\" class=\"ta_links 3bnqmxk\">\r\n<li id=\"p2yaqro9rj\" class=\"njcjjghws\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/partner\/tripadvisor_logo_115x18-15079-2.gif\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-linkingwidgetredesign?amp;locationid=6957605&border=false&uniq=54&lang=en_in&display_version=2\"><\/script>","hotel_img":"pearl harbour.jpg","visibility":"visible","rooms":[{"roomtype_id":"12","hotel_id":"8","type_name":"standard ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"7931","hotel_id":"8","roomtype_id":"12","capacity_id":"0","date_id":"211","cost":"1500","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"300","em":"600","wem":"400"}]},{"roomtype_id":"13","hotel_id":"8","type_name":"triple ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"8526","hotel_id":"8","roomtype_id":"13","capacity_id":"0","date_id":"211","cost":"2000","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"300","em":"600","wem":"400"}]},{"roomtype_id":"14","hotel_id":"8","type_name":"standard non ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"9121","hotel_id":"8","roomtype_id":"14","capacity_id":"0","date_id":"211","cost":"1200","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"300","em":"500","wem":"400"}]},{"roomtype_id":"15","hotel_id":"8","type_name":"triple non ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"9716","hotel_id":"8","roomtype_id":"15","capacity_id":"0","date_id":"211","cost":"1600","available_rooms":"3","booked_rooms":"0","blocked_rooms":"0","meal":"300","em":"500","wem":"400"}]}]},{"hotel_id":"9","hotel_name":"hotel abhishekh","hotel_location":"portblair","hotel_type":"1","hotel_description":"no reviews","hotel_img":"hotel abhishekh.jpg","visibility":"visible","rooms":[{"roomtype_id":"16","hotel_id":"9","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"10311","hotel_id":"9","roomtype_id":"16","capacity_id":"0","date_id":"211","cost":"1500","available_rooms":"8","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"600","wem":"500"}]},{"roomtype_id":"17","hotel_id":"9","type_name":"deluxe","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"10906","hotel_id":"9","roomtype_id":"17","capacity_id":"0","date_id":"211","cost":"1800","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"600","wem":"500"}]}]},{"hotel_id":"10","hotel_name":"hotel phoenix","hotel_location":"portblair","hotel_type":"0","hotel_description":"no reviews","hotel_img":"hotel phoenix.jpg","visibility":"visible","rooms":[{"roomtype_id":"18","hotel_id":"10","type_name":"standard ac ","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"13139","hotel_id":"10","roomtype_id":"18","capacity_id":"0","date_id":"211","cost":"1300","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]},{"roomtype_id":"19","hotel_id":"10","type_name":"standard non ac","meal_plan":"ep","description":"","img":"","inventory":[{"inventory_id":"13730","hotel_id":"10","roomtype_id":"19","capacity_id":"0","date_id":"211","cost":"1000","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]}]},{"hotel_id":"11","hotel_name":"hotel acc","hotel_location":"portblair","hotel_type":"0","hotel_description":"no reviews","hotel_img":"hotel acc.jpg","visibility":"visible","rooms":[{"roomtype_id":"20","hotel_id":"11","type_name":"standard ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"14321","hotel_id":"11","roomtype_id":"20","capacity_id":"0","date_id":"211","cost":"1200","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"400","wem":"300"}]},{"roomtype_id":"21","hotel_id":"11","type_name":"standard non ac","meal_plan":"ep","description":"","img":"","inventory":[{"inventory_id":"14912","hotel_id":"11","roomtype_id":"21","capacity_id":"0","date_id":"211","cost":"1000","available_rooms":"8","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"400","wem":"300"}]}]},{"hotel_id":"12","hotel_name":"anugama resort","hotel_location":"portblair","hotel_type":"2","hotel_description":"<div id=\"ta_cdsratingsonlynarrow458\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"uusjvs\" class=\"ta_links xq2vxynk\">\r\n<li id=\"cxmqyi58s\" class=\"avxbwos7rp\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=1058876&border=false&uniq=458&lang=en_in&display_version=2\"><\/script>","hotel_img":"anugama resort.jpg","visibility":"visible","rooms":[{"roomtype_id":"22","hotel_id":"12","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"15503","hotel_id":"12","roomtype_id":"22","capacity_id":"0","date_id":"211","cost":"3500","available_rooms":"8","booked_rooms":"0","blocked_rooms":"0","meal":"450","em":"1000","wem":"800"}]}]},{"hotel_id":"13","hotel_name":"coastal breeze","hotel_location":"portblair","hotel_type":"1","hotel_description":"no reviews","hotel_img":"coastal breeze.jpg","visibility":"visible","rooms":[{"roomtype_id":"26","hotel_id":"13","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"16094","hotel_id":"13","roomtype_id":"26","capacity_id":"0","date_id":"211","cost":"2500","available_rooms":"6","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"800","wem":"600"}]}]},{"hotel_id":"14","hotel_name":" western park","hotel_location":"portblair","hotel_type":"2","hotel_description":"<div id=\"ta_cdsratingsonlynarrow340\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"bbgm6a\" class=\"ta_links djgpipsov\">\r\n<li id=\"362vxww\" class=\"udotiithe\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=8117352&border=false&uniq=340&lang=en_in&display_version=2\"><\/script>","hotel_img":" western park.jpg","visibility":"visible","rooms":[{"roomtype_id":"23","hotel_id":"14","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"16685","hotel_id":"14","roomtype_id":"23","capacity_id":"0","date_id":"211","cost":"2000","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"800","wem":"600"}]},{"roomtype_id":"24","hotel_id":"14","type_name":"deluxe","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"17276","hotel_id":"14","roomtype_id":"24","capacity_id":"0","date_id":"211","cost":"2500","available_rooms":"6","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"800","wem":"600"}]},{"roomtype_id":"25","hotel_id":"14","type_name":"family(3 bed)","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"17867","hotel_id":"14","roomtype_id":"25","capacity_id":"0","date_id":"211","cost":"3000","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"350","em":"800","wem":"600"}]}]},{"hotel_id":"17","hotel_name":"serenity homes","hotel_location":"portblair","hotel_type":"0","hotel_description":"no reviews","hotel_img":"serenity homes.jpg","visibility":"visible","rooms":[{"roomtype_id":"33","hotel_id":"17","type_name":"standard non ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"18458","hotel_id":"17","roomtype_id":"33","capacity_id":"0","date_id":"211","cost":"1000","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]},{"roomtype_id":"34","hotel_id":"17","type_name":"standard ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"19049","hotel_id":"17","roomtype_id":"34","capacity_id":"0","date_id":"211","cost":"1200","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]},{"roomtype_id":"35","hotel_id":"17","type_name":"standard (triple) ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"20161","hotel_id":"17","roomtype_id":"35","capacity_id":"0","date_id":"211","cost":"2000","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]},{"roomtype_id":"36","hotel_id":"17","type_name":"standard (triple) non ac","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"20822","hotel_id":"17","roomtype_id":"36","capacity_id":"0","date_id":"211","cost":"600","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]},{"roomtype_id":"37","hotel_id":"17","type_name":"four bed ac ","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"21413","hotel_id":"17","roomtype_id":"37","capacity_id":"0","date_id":"211","cost":"2200","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]},{"roomtype_id":"38","hotel_id":"17","type_name":"four bed non ac ","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"22377","hotel_id":"17","roomtype_id":"38","capacity_id":"0","date_id":"211","cost":"1800","available_rooms":"5","booked_rooms":"0","blocked_rooms":"0","meal":"200","em":"500","wem":"400"}]}]},{"hotel_id":"24","hotel_name":"hotel tsg grand","hotel_location":"portblair","hotel_type":"3","hotel_description":"<div id=\"ta_cdsratingsonlynarrow963\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"gig785\" class=\"ta_links cvc6mjd1q\">\r\n<li id=\"an5cec\" class=\"h00mrh3\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=3740803&border=false&uniq=963&lang=en_in&display_version=2\"><\/script>","hotel_img":"hotel tsg grand.jpg","visibility":"visible","rooms":[{"roomtype_id":"48","hotel_id":"24","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"36196","hotel_id":"24","roomtype_id":"48","capacity_id":"0","date_id":"211","cost":"3200","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"450","em":"1500","wem":"1000"}]},{"roomtype_id":"49","hotel_id":"24","type_name":"deluxe","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"36387","hotel_id":"24","roomtype_id":"49","capacity_id":"0","date_id":"211","cost":"3700","available_rooms":"10","booked_rooms":"0","blocked_rooms":"0","meal":"450","em":"1500","wem":"1000"}]}]},{"hotel_id":"25","hotel_name":"kavitha regent","hotel_location":"portblair","hotel_type":"2","hotel_description":"<div id=\"ta_cdsratingsonlynarrow882\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"nmiiqmmwaq\" class=\"ta_links uo3x0oddyz\">\r\n<li id=\"g3oo6h0\" class=\"j2kydkcappao\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=7686880&border=false&uniq=882&lang=en_in&display_version=2\"><\/script>","hotel_img":"kavitha regent.jpg","visibility":"visible","rooms":[{"roomtype_id":"61","hotel_id":"25","type_name":"executive","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"39436","hotel_id":"25","roomtype_id":"61","capacity_id":"0","date_id":"211","cost":"2300","available_rooms":"8","booked_rooms":"0","blocked_rooms":"0","meal":"430","em":"1000","wem":"1000"}]},{"roomtype_id":"62","hotel_id":"25","type_name":"classic","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"40084","hotel_id":"25","roomtype_id":"62","capacity_id":"0","date_id":"211","cost":"2800","available_rooms":"6","booked_rooms":"0","blocked_rooms":"0","meal":"430","em":"1000","wem":"1000"}]},{"roomtype_id":"63","hotel_id":"25","type_name":"imperial","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"40732","hotel_id":"25","roomtype_id":"63","capacity_id":"0","date_id":"211","cost":"3800","available_rooms":"4","booked_rooms":"0","blocked_rooms":"0","meal":"430","em":"1000","wem":"1000"}]}]},{"hotel_id":"27","hotel_name":"sun sea resort","hotel_location":"portblair","hotel_type":"3","hotel_description":"<div id=\"ta_cdsratingsonlynarrow663\" class=\"ta_cdsratingsonlynarrow\">\r\n<ul id=\"itxc38xsb5ax\" class=\"ta_links k8x2ziyk\">\r\n<li id=\"boxpi2\" class=\"adxrmmfpwl\">\r\n<a target=\"_blank\" href=\"https:\/\/www.tripadvisor.in\/\"><img src=\"https:\/\/www.tripadvisor.in\/img\/cdsi\/img2\/branding\/tripadvisor_logo_transp_340x80-18034-2.png\" alt=\"tripadvisor\"\/><\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n'<script src=\"https:\/\/www.tripadvisor.com\/widgetembed-cdsratingsonlynarrow?amp;locationid=1157862&border=false&uniq=663&lang=en_in&display_version=2\"><\/script>","hotel_img":"sun sea resort.jpg","visibility":"visible","rooms":[{"roomtype_id":"58","hotel_id":"27","type_name":"standard","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"41380","hotel_id":"27","roomtype_id":"58","capacity_id":"0","date_id":"211","cost":"3000","available_rooms":"8","booked_rooms":"0","blocked_rooms":"0","meal":"370","em":"1000","wem":"800"}]},{"roomtype_id":"59","hotel_id":"27","type_name":"executive","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"42028","hotel_id":"27","roomtype_id":"59","capacity_id":"0","date_id":"211","cost":"3500","available_rooms":"6","booked_rooms":"0","blocked_rooms":"0","meal":"370","em":"1000","wem":"800"}]},{"roomtype_id":"60","hotel_id":"27","type_name":"family(4 bed)","meal_plan":"cp","description":"","img":"","inventory":[{"inventory_id":"42676","hotel_id":"27","roomtype_id":"60","capacity_id":"0","date_id":"211","cost":"5600","available_rooms":"3","booked_rooms":"0","blocked_rooms":"0","meal":"370","em":"1000","wem":"800"}]}]}]
what want button sort based on hotel start (hotel_type).
any appriciated, thankyou in advance.
data.sort(function(a,b){ if(a.hotel_type < b.hotel_type) return -1; if(a.hotel_type > b.hotel_type) return 1; return 0; })
plunker: http://plnkr.co/edit/gwlqiih0wra8bvinnwvi?p=preview
Comments
Post a Comment