Project: Comment Sorter
Rank a feed of comments by usefulness instead of recency, using a Score as a sort key.
A comment thread sorted by recency shows you the newest comment, not the best one. Sorted by upvotes it shows you the oldest one, because votes accumulate with exposure. Neither ordering is about the thing you actually want, which is whether a comment is useful to someone reading the thread right now.
That is one question, asked once per comment, with the answer used as a sort key. The whole project is a Score, a loop, and a sorted() call.
usefulness score ["Noise", "Low value", "Somewhat useful", "Useful", "Essential"]
Why a Score is right here despite being wrong elsewhere
You have been told a Score expectation is a poor measurement. It is, and nothing about this project changes that. A comment at 2.8 is not eighty percent of the way from “somewhat useful” to “useful” in any sense you could defend, and you should never show that number to a user.
But sorting does not need a measurement. It needs an ordering, and the expectation gives you a clean one: it is monotonic in the distribution, it breaks ties that discrete levels would collapse, and the only property you consume is which of two numbers is larger. The exact same value that would be irresponsible in a dashboard is exactly what you want in a comparator.
Full lesson
Keep reading Project: Comment Sorter
The rest of this lesson — including the interactive exercises and the worked project — is part of Jev Foundations.
- ✓Every lesson in all three courses
- ✓Interactive builders, graders, and playgrounds
- ✓1,000 live Jev credits, for the courses and the playground
- ✓Project source you can run yourself
- ✓Free updates as Jev ships new versions
Already bought them? Sign in to unlock — no need to buy twice.