diff --git a/js/history.js b/js/history.js index 49ff213..4868ad9 100644 --- a/js/history.js +++ b/js/history.js @@ -103,7 +103,13 @@ function renderHistoryTable() { } const nameById = Object.fromEntries(state.employees.map(e => [e.id, e.name])); - const sorted = [...state.history].sort((a, b) => b.date.localeCompare(a.date)); + const sorted = [...state.history].sort((a, b) => { + const dateCmp = b.date.localeCompare(a.date); + if (dateCmp !== 0) return dateCmp; + const nameA = nameById[a.employeeId] ?? ''; + const nameB = nameById[b.employeeId] ?? ''; + return nameA.localeCompare(nameB, 'de'); + }); const table = document.createElement('table'); const thead = document.createElement('thead'); @@ -137,7 +143,7 @@ function renderHistoryTable() { delBtn.textContent = '✕'; delBtn.style.cssText = 'font-size:11px;padding:2px 6px'; delBtn.addEventListener('click', () => { - removeHistoryEntry(state, h.date); + removeHistoryEntry(state, h.date, h.employeeId); saveState(); renderHistoryTable(); });