Hierarchical table display w/ sorting

Hello – I'm looking for a decent way to display hierarchical information within a table that will also allow users the ability to sort records by clicking the top of each column of associated discrete data. When the user sorts, the records would be restacked thus removing the hierarchical view/UI. To go back to the default hierarchical view, the user would click the top of the 'Record' column. The use case here is to allow a user to evaluate the data in a few different ways then make a selection to perform an action such as 'View/Export Records' or 'View Details'

Ive attached a conceptual model of what we currently have for reference but I'm curious if there is a better way to display hierarchical info on a table that can be sorted and selected?

Thank you for the help.

enter image description here