Cleaned up duplicate code for sorting/splitting tags in views.