JSFiddle - React, Tailwind, and code Playground
HTML
<div class="tab-content">
<div id="filters">
<p>
<a class="sortByRating" href="#" >Sort by Rating</a>
<br>
<a class="sortByPrice" href="#">Sort by Price</a>
</p>
</div>
<div id="div_hotel_results" class="tab-pane active">
<form id="hotel-form">
...
</form>
<div class="results">
<div class="results-row">
<h5>Riders Lodge</h5>
<span class="label label-info price">$103.64</span>
<span class="rating" data-rating="3.0">3.0</span>
</div>
<div class="results-row">
<h5>Olina Lodge</h5>
<span class="label label-info price">$99.64</span>
<span class="rating" data-rating="2.5">2.5</span>
</div>
</div>
</div>
</div>
JavaScript
var ascending = false;
$('.tab-content').on('click','.sortByPrice',function(){
var sorted = $('.results-row').sort(function(a,b){
return (ascending ==
(convertToNumber($(a).find('.price').html()) <
convertToNumber($(b).find('.price').html()))) ? 1 : -1;
});
ascending = ascending ? false : true;
$('.results').html(sorted);
});
var convertToNumber = function(value){
return parseFloat(value.replace('$',''));
}