As an absolute javascript beginner, I am currently practicing on a todo app. The entries should be sorted by title, date, status and priority by clicking on the column header. Attached is my attempt, however I seem to be doing something wrong. Can anyone help me with this?
const todos = [
  {id: 1, duedate: "2023-06-30", title: "Javascript Project 1", description: "first try", prio: 1, state: "done"}
];
const titleSort = document.getElementById("sort-title");
function sortTitle(a, b) {
  // alert("Titel sortieren");
  const titleA = a.title.toUpperCase();
  const titleB = b.title.toUpperCase();
  let comparison = 0;
  if (titleA > titleB) {
    comparison = 1;
  } else if (titleA < titleB) {
    comparison = -1;
  }
  return comparison;
}
titleSort.addEventListener("click", sortTitle);
 
    