JSFiddle - React, Tailwind, and code Playground

HTML

<ul id="sort-menu">
    <li>3</li>
    <li>2</li>
    <li>8</li>
    <li>1</li>
    <li>5</li>
    <li>1</li>
</ul>

JavaScript

var sorted = $("#sort-menu > li").sort(function (a, b) {
    // in this case, the a and b are LI elements
    // which means that we need to parse their contents into integers before comparing them
    return parseInt(a.innerHTML) - parseInt(b.innerHTML);
});

sorted.detach().appendTo($("#sort-menu"));