Implement sorting by role/class, partial alphabetical

Implement sorting by role/class, partial alphabetical ordering - still
not fully working.