diff --git a/public/index.php b/public/index.php index 278a638..a4d43e5 100644 --- a/public/index.php +++ b/public/index.php @@ -171,6 +171,7 @@ $news_items = $stmt->fetchAll(); diff --git a/public/js/app.js b/public/js/app.js index 6c150b1..4182709 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -832,10 +832,15 @@ function updateContributionsList() { // Sorts by selected Option var sortBy = document.getElementById('list-sort') ? document.getElementById('list-sort').value : 'date-desc'; filtered.sort(function (a, b) { - if (sortBy === 'date-desc') return new Date(b.properties.created_at) - new Date(a.properties.created_at); - if (sortBy === 'date-asc') return new Date(a.properties.created_at) - new Date(b.properties.created_at); - if (sortBy === 'likes') return b.properties.likes_count - a.properties.likes_count; - if (sortBy === 'comments') return (b.properties.comment_count || 0) - (a.properties.comment_count || 0); + if (sortBy === 'date-desc') return new Date(b.properties.created_at) - new Date(a.properties.created_at); + if (sortBy === 'date-asc') return new Date(a.properties.created_at) - new Date(b.properties.created_at); + if (sortBy === 'likes') return b.properties.likes_count - a.properties.likes_count; + if (sortBy === 'comments') return (b.properties.comment_count || 0) - (a.properties.comment_count || 0); + if (sortBy === 'category') { + var catA = (CATEGORIES[a.properties.category] || CATEGORIES.other).label; + var catB = (CATEGORIES[b.properties.category] || CATEGORIES.other).label; + return catA.localeCompare(catB); + } return 0; });