Skip to content

Commit

Permalink
Added Sorting
Browse files Browse the repository at this point in the history
Decoration sorting from most to least amount of decors in a collection, (Thanks to k4lmaa for the idea)
  • Loading branch information
Yeetov authored Dec 15, 2024
1 parent 5a568df commit 288b693
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h1>Decoration Gallery</h1>
<div id="grid" class="grid"></div>

<script>
// Fetch logos and decorations from separate json files dynamically
// Fetch logos and decorations from separate JSON files dynamically
function loadGroupLogos() {
return fetch('https://raw.githubusercontent.com/DiscoLook/discolook.github.io/refs/heads/main/group_logos.json?' + Date.now())
.then(response => response.json())
Expand Down Expand Up @@ -194,7 +194,10 @@ <h1>Decoration Gallery</h1>
const grid = document.getElementById('grid');
grid.innerHTML = ''; // Clear any existing content

Object.entries(data.groups).forEach(([groupName, groupItems]) => {
// Sort groups by the number of decorations (descending order)
const sortedGroups = Object.entries(data.groups).sort((a, b) => b[1].length - a[1].length);

sortedGroups.forEach(([groupName, groupItems]) => {
// Create and append group title
const groupTitle = document.createElement('h2');
groupTitle.className = 'group-title';
Expand Down

0 comments on commit 288b693

Please sign in to comment.