I am looking to implement a dropdown sorting functionality for multiple divs based on different data attributes such as price and popularity. The specific divs are labeled as "element-1" and are contained within the "board-container".
var divList = $(".element-1");
function sortPrice(){
divList.sort(function(a, b){ return
$(a).data("price")-$(b).data("price")});
$(".board-container").html(divList);}
function sortPopularity(){
divList.sort(function(a, b){ return
$(a).data("popularity")-$(b).data("popularity")});
$(".board-container").html(divList);}
<div class="board-container">
<div class="element-1" data-date="4" data-popularity="3">
<a class="group1" href="img/zayn.png">
<div class="overlay-wrapper">
<div class="overlay-text">
<div class="table">
<div class="cell">
<div class="title">King Kunta</div>
<div class="artist">Kendrick Lamar</div>
</div>
</div>
</div>
</div>
<img src="img/kunta.png">
</div>
<div class="element-1" data-date="3" data-popularity="3">
<a class='youtube' href="https://www.youtube.com/embed/C_3d6GntKbk? rel=0&wmode=transparent">
<div class="overlay-wrapper">
<div class="overlay-text">
<div class="table">
<div class="cell">
<div class="title">King Kunta</div>
<div class="artist">Kendrick Lamar</div>
</div>
</div>
</div>
</div>
<img src="img/astrid.png">
</div>
<div class="element-1" data-date="1" data-popularity="12">
<a class='youtube' href="https://www.youtube.com/embed/C_3d6GntKbk?rel=0&wmode=transparent">
<div class="overlay-wrapper">
<div class="overlay-text">
<div class="table">
<div class="cell">
<div class="title">King Kunta</div>
<div class="artist">Kendrick Lamar</div>
</div>
</div>
</div>
</div>
<img src="img/zayn.png">
</div>
<div class="element-1" data-date="5" data-popularity="1">
<div class="overlay-wrapper">
<div class="overlay-text">
<div class="table">
<div class="cell">
<div class="title">King Kunta</div>
<div class="artist">Kendrick Lamar</div>
</div>
</div>
</div>
</div>
<img src="img/jason.png">
</div>
</div>