JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="terminal" data-price="195">
<h3>195</h3>
</div>195 - I should come in 2nd.</div>
<div class="container">
<div class="terminal" data-price="220">
<h3>220</h3>
</div>220 - I should come in 3rd.</div>
<div class="container">
<div class="terminal" data-price="130">
<h3>130</h3>
</div>130 - I should come in 1st.</div>
CSS
.container {
width:250px;
border:1px solid #ddd
}
JavaScript
function sorter(a, b) {
return a.getAttribute('data-price') - b.getAttribute('data-price');
};
var sortedDivs = $(".terminal").toArray().sort(sorter);
console.log(sortedDivs);
$(".container").remove();
$.each(sortedDivs, function (index, value) {
$('body').append(value);
});