Sort items in Reminders list alphabetically by Title

I know that you can VIEW items in a reminders list sorted by Title, etc. on macOS but the actual order remains unsorted. Because there is no such view option in iOS, that means that I must manually sort my Reminders for iOS (if I want to view alphabetically).

I have over 100 reminders at any one time, and the UX for manually sorting this many items is rough.

How can I (manually) sort all items in a Reminders list, alphabetically, by the Title of the reminder?

Well. On my Mac, Reminders returns its ‘reminders’ to a script in ‘creation date’ order. If that’s the order in which they’re displayed in iOS, and if your reminders are suitably synchronised between a Mac and an iOS device, a somewhat inelegant method would be to get the properties of the reminders you want to sort, delete the reminders, sort the list of property records by ‘name’, and then recreate the reminders from the sorted records at one-second intervals. It works on a Mac where Reminders is displaying reminders sorted by Creation Date, but I don’t have any iOS devices with which to test the idea further.

The script below assumes you have this customisable sort installed as a library on the machine running the script. Save the sort as a compiled script in ~/Library/Script Libraries/ under the name “Custom Iterative Dual-Pivot Quicksort.scpt”. (Or use some other name and edit the ‘use sorter …’ line at the top of the script below to match.)

The ‘delete relevantReminders’ line at the end of the first ‘tell’ statement is commented out so that you can test the script without losing your existing reminders. Uncomment this line if/when you’re satisfied.

use AppleScript version "2.3.1" -- Mac OS 10.9 (Mavericks) or later.
use sorter : script "Custom Iterative Dual-Pivot Quicksort"
use scripting additions

tell application "Reminders"
	set relevantReminders to a reference to (its reminders where completed is false) -- Adjust the reference as required.
	-- Get the properties of the existing reminders as a list of AppleScript records.
	set reminderProperties to properties of relevantReminders
	-- Delete the existing reminders.
	-- delete relevantReminders -- Uncomment this line to enable deletions.
end tell

-- This is a sort customiser which compares reminder property records by 'name', comparing by 'due date' too if the names are the same. Where a 'due date' comparison takes place, any record whose 'due date' is 'missing value' goes after any whose 'due date' is a date.
script byNameThenDueDate
	using terms from application "Reminders"
		on isGreater(a, b)
			set nameA to a's name
			set nameB to b's name
			if (nameA = nameB) then
				set dueDateA to a's due date
				set dueDateB to b's due date
				if (dueDateA is missing value) then
					return (dueDateB is not missing value)
					return ((dueDateB is missing value) or (dueDateA > dueDateB))
				end if
				return (nameA > nameB)
			end if
		end isGreater
	end using terms from
end script

-- Sort items 1 thru -1 of the list of property records, using the customiser above.
tell sorter to sort(reminderProperties, 1, -1, {comparer:byNameThenDueDate})

-- Work through the sorted list, creating new reminders with the same properties.
repeat with theseProperties in reminderProperties
	tell application "Reminders"
		set {name:thisName, body:thisBody, completed:thisCompleted, completion date:thisCompletionDate, container:thisContainer, due date:thisDueDate, remind me date:thisRemindMeDate, priority:thisPriority} to theseProperties
		set propertiesForNewReminder to {name:thisName, completed:thisCompleted}
		if (thisCompleted) then set propertiesForNewReminder to propertiesForNewReminder & {completion date:thisCompletionDate}
		if (thisBody is not missing value) then set propertiesForNewReminder to propertiesForNewReminder & {body:thisBody}
		if (thisDueDate is not missing value) then set propertiesForNewReminder to propertiesForNewReminder & {due date:thisDueDate}
		if (thisRemindMeDate is not missing value) then set propertiesForNewReminder to propertiesForNewReminder & {remind me date:thisRemindMeDate}
		if (thisPriority is not missing value) then set propertiesForNewReminder to propertiesForNewReminder & {priority:thisPriority}
		make new reminder at end of reminders of thisContainer with properties propertiesForNewReminder
		-- Delay at least a second between reminder creations to get a different creation date for each.
		delay 1
	end tell
end repeat