JSFiddle - React, Tailwind, and code Playground
HTML
Click on the table headings to sort the results.
<table>
<thead id="headings">
<tr>
<th id="hotel_name">Hotel Name</th>
<th id="minPrice">Price</th>
<th id="hotel_star">Star</th>
</tr>
</thead>
<tbody id="results">
<!-- this will be auto-populated -->
</tbody>
</table>
CSS
table {
margin: 3px;
}
table th {
font-weight: bold;
cursor: pointer;
}
table th, table td {
padding: 3px;
border: 1px solid #000;
}
JavaScript
var arr = [
{
"hotel_id": "00001065",
"hotel_name": "The Infantry Hotel",
"hotel_star": "3",
"image": "",
"location": "Infantry Road",
"minPrice": "2,497",
"RoomTypes": [
{
"RoomTypeName": "Deluxe King / Twin Double",
"AvailableQuantity": "4",
"RatePlanInclusions": "Complimentary Wi-Fi Internet",
"price": "2,497"
},
{
"RoomTypeName": "Superior Double",
"AvailableQuantity": "2",
"RatePlanInclusions": "Breakfast",
"price": "3,496"
}
]
},
{
"hotel_id": "00001080",
"hotel_name": "Hotel Ramanashree",
"hotel_star": "3",
"image": "",
"location": "Richmond Road",
"minPrice": "3,879",
"RoomTypes": [
{
"RoomTypeName": "Executive Room",
"AvailableQuantity": "25",
"RatePlanInclusions": "Breakfast",
"price": "3,879"
},
{
"RoomTypeName": "Club Room",
"AvailableQuantity": "25",
"RatePlanInclusions": "Breakfast",
"price": "4,604"
}
]
},
{
"hotel_id": "00003757",
"hotel_name": "The Paul ",
"hotel_star": "5",
"image": "",
"location": "Domlur Layout",
"minPrice": "6,216",
"RoomTypes": [
{
"RoomTypeName": "Executive Suite - Two Bedrooms Suite",
"AvailableQuantity": "4",
"RatePlanInclusions": "Complimentary Wi-Fi Internet, Breakfast",
"price": "8,942"
},
{
"RoomTypeName": "Premier Suite - Two Bedrooms Suite",
"AvailableQuantity": "2",
"RatePlanInclusions": "Complimentary Wi-Fi Internet, Breakfast",
"price": "10,718"
},
{
"RoomTypeName": "Studio Suite - One Bedroom Suite",
"AvailableQuantity": "4",
...