Skip to content

Instantly share code, notes, and snippets.

@clemlatz
Last active September 28, 2018 07:48
Sort guests
(function() {
const getLastName = guest => {
const title = guest.querySelector('.title-nom-prenom');
const names = title.textContent.split(' ');
return names[names.length - 1];
}
const isotope = document.querySelector('#isotope-list-invites');
const guests = Array.prototype.slice.call(isotope.querySelectorAll('a'));
guests.sort((a, b) => {
const aLastName = getLastName(a);
const bLastName = getLastName(b);
if (aLastName > bLastName) return 1;
if (bLastName < aLastName) return -1;
return 0;
});
isotope.innerHTML = '';
isotope.appendChild(guests[0]);
})();
//guests.forEach(guest => guest.remove());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment