Sort list items alphabetically

Change the orderby to be alphabetical based on a data attribute on list items.

HTML

Nicer
<div class="thisdiv">

    <tr data-position="x">Item 3</tr>
    <tr data-position="a">Item 2</tr>
    <tr data-position="b">Item 1</tr>
    <tr data-position="s">Item 4</tr>
    
</div>

JavaScript

$(".thisdiv tr").sort(sort_li).appendTo('.thisdiv');
function sort_li(a, b){
    return ($(b).data('position')) < ($(a).data('position')) ? 1 : -1;    
}