Select the code you wish to sort in Visual Studio Code.
Then hit the key combination Ctrl+P and type the greater than sign (>). Next type sort and choose Sort Lines Ascending or choose the Descending option.
Now the lines you’ve previously selected will be sorted by the option you chose. One thing to keep in mind is that if you have lines which have breaks in them, the second line will also be sorted into the mix. Which may mess up formatting for things like CSS Property values.