Sort the classes hierarchically when popped up