document.addEventListener("DOMContentLoaded", () => {
const wrapper = document.querySelector(".wrapper");
const grids = [...wrapper.querySelectorAll("[id^='grid-']")].filter(
(el) => /^grid-\d{4}$/.test(el.id)
);
const anchor = grids[grids.length - 1].nextSibling;
grids
.sort((a, b) => b.id.localeCompare(a.id))
.forEach((el) => wrapper.insertBefore(el, anchor));
});