JSFiddle - React, Tailwind, and code Playground
HTML
<div rel="5">
Divs content goes here
</div>
<div rel="3">
Div 3 Here
</div>
<div rel="4">
Div 4 Here
</div>
<div rel="4.5">
Div 4.5 here
</div>
JavaScript
var array = new Array();
$('div').each(function(){
array.push($(this).attr('rel'));
});
array = array.sort();
var reordedDivs = "";
$.each(array, function(i, obj1){
$('div').each(function(j, obj2) {
if ($(obj2).attr('rel') == obj1) {
var divContent = $(obj2).html();
var rel = obj1;
reordedDivs += "<div rel='" + rel + "'>" + divContent + "</div>";
}
});
});
$('body').html(reordedDivs);