First, get Department.all() out of your view. It doesn't belong there.
It's not the responsibly of the view to load it's own data. Put that in
the controller where it belongs.
How do I sort the display names by the hospital name (which is a few
"tables away" in the db schema), and then by the department name.
The relationship in the db is as follows:
department-->floor-->building--> hospital.
Given that it sounds like your list of results is small enough to fetch
them all into memory, then you can sort them in memory using Ruby, I'll
leave that as an exercise for you.