Below example explains on how to use grouping and sorting functionality in an XSL file.
The first group is on "location" and then we are trying to group the sublist of records based on "department". Sorting is based on "department" within the sublist of records for a given "location".
Full source code can be downloaded by clicking here.
Hope this helped you.