I used this question (jQuery sort elements using data id) to get a lot of work done on a project I'm doing.
The top voted answer mentions that using jQuery;s .data()
is required if I need it to work in IE10 and below. I haven't tested it in any of those browsers, but I have found that it does not work in IE11 or Edge.
Here's the jsfiddle that works just fine in Chrome for me: http://jsfiddle.net/4o771n7o/
HTML
<div class="clist">
<div data-sid=1>1</div>
<div data-sid=4>4</div>
<div data-sid=3>3</div>
<div data-sid=1>1</div>
<div data-sid=4>4</div>
<div data-sid=2>2</div>
<div data-sid=1>1</div>
</div>
Javascript
$('.clist div').sort(function(a,b) {
return $(a).data('sid') > $(b).data('sid');
}).appendTo('.clist');