Couldn't this be written as

<pre>
Project.public.users.active.sort.group_by(&:class)
</pre>
?