These `#sort_by`s aren't working.  Use sets instead.