Skip to content

Commit

Permalink
profiles are sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
chaanakyaaM committed Oct 20, 2024
1 parent 37d1747 commit 3f68aaf
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions project.html
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,33 @@ <h3 class="name">Suramya Ranjan</h3>
<script type="module" src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.esm.js"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/ionicons/ionicons.js"></script>
<script src="script.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {

const container = document.querySelector('.container');

const profiles = Array.from(container.querySelectorAll('.profile'));

profiles.sort((a, b) => {
const nameA = a.querySelector('.name').textContent.toUpperCase();
const nameB = b.querySelector('.name').textContent.toUpperCase();

if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
});

container.innerHTML = '';

profiles.forEach(profile => {
container.appendChild(profile);
});
});
</script>

</body>

Expand Down

0 comments on commit 3f68aaf

Please sign in to comment.