I have disorder div in HTML page and that need to in ascending order based on their id. I have some code but it is not working I just want to know what is wrong with code or do i need to do some more work with code. fiddle
Jquery
$('div').sort(function (a, b) {
var contentA =parseInt( $(a).attr('data-sort'));
var contentB =parseInt( $(b).attr('data-sort'));
return (contentA < contentB) ? -1 : (contentA > contentB) ? 1 : 0;
})
HTML
<div data-sort='14'>14</div>
<div data-sort='6'>6</div>
<div data-sort='9'>9</div>