JSFiddle - React, Tailwind, and code Playground

HTML

<div id="content">
    <div position="4">4</div>
    <div position="1">1</div>
    <div position="3">3</div>
    <div position="2">2</div>
    <div position="5">5</div>
</div>
<div id="results">
</div>

CSS

#content div {
    display:none;
}

JavaScript

var myArray = $("#content div");
myArray.sort(function (a, b) {

    // convert to integers from strings
    a = parseInt($(a).attr("position"));
    b = parseInt($(b).attr("position"));

    // compare
    if(a > b) {
        return 1;
    } else if(a < b) {
        return -1;
    } else {
        return 0;
    }
});

// put sorted results back on page
$("#results").append(myArray);