Corrected a sorting issue and added a fix for the case where an IdP as a category that is not defined