Suppose I have the following text:
int z; int a; int c; int g; or the following text:
z, a, c, g
How can I sort them to:
int a; int c; int g; int z; and
a, c, g, z respectively?
Use M-x sort-lines for the first example. For the second example, change it into
z, a, c, g, then use M-x sort-regexp-fields <RET> ., <RET> \& <RET>.
., is specific to this example, if you need more generic patterns for coma separated words, you can use \s-?\w+,?