I have three different "first name, last name" action groups, depending on the artist's name.
First, copy ARTIST into ARTISTSORT:
Action type: Format value
Field: ARTISTSORT
Format string: %artist%
- The standard one that I'm sure everyone has seen, used for simple names with a single word in the last name.
Frank Sinatra -> Sinatra, Frank
Stevie Ray Vaughan -> Vaughan, Stevie RayAction type: Replace with regular expression
[ ] case-sensitive comparison
Field: ARTISTSORT
Regular expression: ^(.+)\s(.+)$
Replace matches with: $2, $1 - One for artists with two or more words in the last name.
Townes Van Zandt -> Van Zandt, Townes
Miguel De La Bastide -> De La Bastide, MiguelAction type: Replace with regular expression
[ ] case-sensitive comparison
Field: ARTISTSORT
Regular expression: ^([^\s]+)\s(.+)$
Replace matches with: $2, $1 - And one for names with suffixes such as Jr., Sr., etc.
Harry Connick Jr. -> Connick, Harry Jr.
Hank Williams III -> Williams, Hank IIIAction type: Replace with regular expression
[ ] case-sensitive comparison
Field: ARTISTSORT
Regular expression: ^(.+)\s([^\s]+)\s(.+)$
Replace matches with: $2, $1 $3