I am working on a list of divs that contain custom data-attributes that I want to sort with a selection. If selected for example 'followers' it will be sorted after the .box's data-followers.
My jsfiddle: https://jsfiddle.net/nbgo117b/
I was thinking something like this, but I can't make it work.
$("#sorter").change(function() {
var value = $("#sorter option:selected").val();
var boxOrdered;
if (value == 'date' ){
boxOrdered = $('.influencer .box').sort(function(a, b){
return ($(b).data('followers')) < ($(a).data('followers')) ? 1 : -1;
});
}
$(".influencer").html(boxOrdered);
});