This Function is used to sort divs depending on their like count
for some reason it works really fine except when it gets higher than 9
then suddenly 12 is < 8 for example ?
$(document).on("click", ".textbox", function() {
let likes = parseInt($(this).closest(".textbox").find("span").text());
console.log(likes)
$(this).closest(".textbox").find("span").text(likes + 1);
});
$("#sort").on("click", function() {
let divs = $(".boxwrapper")
let sorted = divs.sort(function(a, b) {
return $(a).find("span").text() < $(b).find("span").text() ? 1 : -1;
});
$(".container").append(sorted);
});