Nice of you to share this!
Tip: The grouping and sorting can be accomplished even easier (albeit making it less of a vim feature showcase) by simply running :sort with no visual selection - it will sort the entire buffer, including grouping by prefix.