Most are from the Discord ## Sorting Pass these as the sorting functions like so ``` const sorted = pages.sort(sortFunction); ``` ``` const sortByNameAsc = (a,b) => a.$name > b.$name ? -1 : 1 const sortByNameDesc = (a,b) => b.$name < a.$name ? 1 : -1 const sorted = pages.sort(critWay === "asc" ? sortByNameAsc : sortByNameDesc); ``` ### sortByDate ```jsx // creates helper function const createSortByDate = (date = "Created", critWay = 'asc') => { return (a, b) => { const valueA = a[date]; const valueB = b[date]; // Compare values if (valueA > valueB) { return critWay === 'asc' ? 1 : -1; } else if (valueA < valueB) { return critWay === 'asc' ? -1 : 1; } return 0; // Equal values }; }; ```