Problem — Sorting Reminders By Priority

Numbers 0… 1… 5… and 9The progress on the Reminders widget is quite nice. As an example, the sorting is robust. By default, the reminders are sorted alphabetically and then by date. That way, the most important reminders rise to the top. Events can also be sorted by completion (checkmarks) and by category. There’s only one sort left — sorting by priority. There’s a problem here. It has to do with the numbers 0… 1… 5… and 9.

JavaScript is by far my favorite programming language. It’s essentially English of the Internet. It’s common and fairly easy to learn. But with Reminders, that’s specifically Apple technology. That means using Swift. I like Swift too, but there are some Apple oddities mixed in. That is especially apparent with sorting reminders by priority. It should be a simple one-line action…

.sort(by: { $0.priority < $1.priority })

That doesn’t work though, as the values for “priority” are illogical.

  • “Low” Priority — One Exclamation Point (!) = 9
  • “Medium” Priority — Two Exclamation Points (!!) = 5
  • “High” Priority — Three Exclamation Points (!!!) = 1
  • No Priority — No Exclamation Points = 0

If “High” priority was a 9, instead of a 1, this would be no problem. If no priority was a 10 instead of a 0, it would also be no trouble. Instead, there’s a collision with the order.

Math can be added into the sort. I’ve been trying to figure out a way to mathematically rearrange the values. Perhaps through arithmetic, priority values can be changed into something more suitable for sorting. Since anything times zero is still zero, that might be able to shift the numbers around. But so far, I’m still stuck on this perplexing problem. I was also reminded that dividing by zero is bad. HA HA!

There are many ways to solve this problem. I don’t have to use a mathematical solution, but I do enjoy the challenge. This reminds me of the great minds in mathematics. How did they do it? The legends of yore didn’t have computers. Many didn’t even have indoor plumbing. And yet, they figured out such complex problems. While not as significant as the Pythagorean Theorem, there is merit in solving this problem.

While battling with the quirks of Swift, the new Reminders widget is feeling like a significant improvement over Apple’s standard widget. Reminders are very useful, but I don’t remember seeing anyone using it regularly. Instead, people opt to jot things down on a piece of paper. That suggests the software needs improvement. Perhaps the Widgets app is the solution to that problem.

Widgets Reminder Preview — Groceries

That’s what’s really nice about this new widget. I’m really looking forward to using it. I think it’s helpful and it’s likely to improve the way I work. Perhaps you’ll feel the same way. The widget is being built to be helpful. This is project is more challenging than expected, but the goal is to make tools that people want to use.

There’s still more work to do. Sorting is only one of the four major features planned for this new widget. Hopefully you’ll be able to use this new widget soon.

One thought on “Problem — Sorting Reminders By Priority”

  1. I was hoping to devise a super elegant formula, in order to sort the reminders by priority. Instead, I ended up writing an extension…

    extension Int {
        var noZeros: Int {
            var x = self
            if self == 0 {
                x = 10
            return x

    If the number is zero, return 10. This is not exactly the splendor of… A² + B² = C² …or… e=MC² …but I’m developer, not a mathematician.

Comments are closed.