Stay tuned for a more elegant version…
copy some lines then
This comes up at the top of searches still so I’ll add this latest solution. If you are running a current VS Code (and why wouldn’t you?) you can use the built-in sorter by hitting ctrl-shift-p (Mac is cmd-shift-p) and type “sort” in the subsequent search box. There are many options.
https://stackoverflow.com/questions/3350793/sort-selected-text-from-visual-studio-context-menu