Skip to content

Instantly share code, notes, and snippets.

@yangshun
Created February 24, 2014 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yangshun/9183114 to your computer and use it in GitHub Desktop.
Save yangshun/9183114 to your computer and use it in GitHub Desktop.
This snippet of code can be used to sort the posts within each tag category on the DailyJS site: http://dailyjs.com/tags.html
(function() {
$('.posts').each(function() {
var $postsInCat = $(this).children();
var $sortedCat = $postsInCat.sort(function(a, b) {
var dateA = new Date($(a).children('div').html());
var dateB = new Date($(b).children('div').html());
return dateA < dateB ? 1 : -1;
});
$(this).html('').html($sortedCat);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment