In this episode, we focus on making the list of notes more user-friendly by ordering them based on their last edited timestamp. First, we notice that our fake notes don't have real last edited times yet, so we use some placeholder values just for demonstration.
We walk through adding a getter (or computed property) that returns a sorted array of the notes, with the most recently edited note at the top. This involves a quick refresher on how to use JavaScript's sort
method with a custom comparison function. We then hook this up so our UI shows the notes in the correct order automatically.
We also address a subtle bug: even after reordering the notes, the editor may not be showing the most recently edited note. This happens because we're still using the old, unsorted list when deciding what to show. After updating the code to use the ordered list everywhere, the bug is fixed—the editor always shows the top (most recently edited) note.
To wrap up, we preview the next step: allowing users to click on any note to bring it into the editor, and ensuring that when a note is edited, it's bumped to the top of the list. That way, our app behaves just like a polished notes app should.