Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Add smooth scrolling
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function (e) {
+ e.preventDefault();
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
+ behavior: 'smooth'
+ });
+ });
+ });
+
+ // Add table sorting functionality
+ const tables = document.querySelectorAll('table');
+ tables.forEach(table => {
+ const headers = table.querySelectorAll('th');
+ headers.forEach((header, index) => {
+ header.addEventListener('click', () => {
+ sortTable(table, index);
+ });
+ header.style.cursor = 'pointer';
+ });
+ });
+ });
+
+ function sortTable(table, column) {
+ const tbody = table.querySelector('tbody');
+ const rows = Array.from(tbody.querySelectorAll('tr'));
+ const isNumeric = rows.every(row =>
+ !isNaN(row.children[column].textContent.trim())
+ );
+
+ rows.sort((a, b) => {
+ const aValue = a.children[column].textContent.trim();
+ const bValue = b.children[column].textContent.trim();
+
+ return isNumeric
+ ? Number(aValue) - Number(bValue)
+ : aValue.localeCompare(bValue);
+ });
+
+ tbody.append(...rows);
+ }