Skip to content

Instantly share code, notes, and snippets.

@jalbertbowden
Forked from iwek/pinterest-4.js
Created April 27, 2013 01:45
Show Gist options
  • Save jalbertbowden/5471557 to your computer and use it in GitHub Desktop.
Save jalbertbowden/5471557 to your computer and use it in GitHub Desktop.
//cleanup and sort elemets that have likes
//cleanup for likes
$(".LikesCount").each(function() {
var num = Number($(this).text().trim().replace("likes", "").replace("like", ""));
$(this).html(num);
});
//sort
var mylist = $('.pin');
var listitems = mylist.find('.LikesCount:not(:contains(0))'); //do not match on elements that have 0 likes
listitems.sort(function(a, b) {
var compA = Number( $(a).text() );
var compB = Number( $(b).text() );
return compA > compB ? -1 : 1;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment