JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>4</li>
<li>2</li>
<li>3</li>
<li>1</li>
</ul>
JavaScript
(function () {
function ordenar(a, b) {
return parseInt(a.innerHTML, 10) > parseInt(b.innerHTML, 10);
}
var ul = document.querySelector('ul');
var lis = ul.querySelectorAll('li');
var impares = [];
var pares = [];
[].forEach.call(lis, function (el) {
var nr = parseInt(el.innerHTML, 10);
if (nr % 2 == 0) pares.push(el);
else impares.push(el);
ul.removeChild(el);
});
[pares, impares].forEach(function (arr) {
arr.sort(ordenar).forEach(function (el) {
ul.appendChild(el);
});
});
})();