Skip to content

Instantly share code, notes, and snippets.

@jalbertbowden
Forked from iwek/pinterest-2.js
Created April 27, 2013 01:45
Show Gist options
  • Select an option

  • Save jalbertbowden/5471559 to your computer and use it in GitHub Desktop.

Select an option

Save jalbertbowden/5471559 to your computer and use it in GitHub Desktop.
//cleanup and sort elemets that have repins
//grab all pins
var mylist = $('.pin');
//find all pins that have repins
var listitems = mylist.find('.RepinsCount');
//trim the contents of the repins element to just a number and compare them against each other to sort
listitems.sort(function(a, b) {
var compA = Number( $(a).text().trim().replace("repins", "").replace("repin", "") );
var compB = Number( $(b).text().trim().replace("repins", "").replace("repin", "") );
return compA > compB ? -1 : 1;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment