This was erroring with nil departments. So I am stripping out the nil departments before sorting.