JSFiddle - React, Tailwind, and code Playground

by Serge Zahharenko

HTML

<ul id="test">
    <li id="i4112">4112</li>
    <li id="i1422">1422</li>
    <li id="i6640">6640</li>
    <li id="i2221">2221</li>
</ul>

JavaScript

$(function(){
    var order = ['i2221', 'i6640', 'i4112', 'i1422'];
    var elems = $('#test').children();
    elems.sort(function(a,b){
        return order.indexOf(a.id) > order.indexOf(b.id);
    });
    //console.log(elems);
    $('#test').html(elems);
});