index.js
function sortPosts( a, b ) {

	var dateA = new Date( a.created ),
			dateB = new Date( b.created );

	// See if dates match
	if ( dateB - dateA === 0 ) {

		// See if categories are the same
		if ( a.category === b.category ) {

			// Sort by title
			return a.title.localeCompare( b.title );

		// Sort by category
		} else {

			return a.category.localeCompare( b.category );
		}

	// Sort by date descending
	} else {

		return dateB - dateA;
	}
}
function sortPosts( a, b ) {

	var dateA = new Date( a.created ),
			dateB = new Date( b.created );

	// See if dates match
	if ( dateB - dateA === 0 ) {

		// See if categories are the same
		if ( a.category === b.category ) {

			// Sort by title
			return a.title.localeCompare( b.title );

		// Sort by category
		} else {

			return a.category.localeCompare( b.category );
		}

	// Sort by date descending
	} else {

		return dateB - dateA;
	}
}
function sortPosts ( a , b ) { var dateA = new Date ( a . created ) , dateB = new Date ( b . created ) ; // See if dates match if ( dateB - dateA === 0 ) { // See if categories are the same if ( a . category === b . category ) { // Sort by title return a . title . localeCompare ( b . title ) ; // Sort by category } else { return a . category . localeCompare ( b . category ) ; } // Sort by date descending } else { return dateB - dateA ; } }
Sort posts. By default posts are sorted by
date descending, category, title

@param {Object} a
@param {Object} b
Sort posts . By default posts are sorted by date descending category title