Action TITLESORT to acquire TITLE with "The" or "A" appended

As an example, I wish to define an action where TITLESORT for a TITLE such as "The Great Pretender" acquires the value "Great Pretender, The" while the TITLE value itself remains unchanged. My searches in this forum for any similar previous questions were unsuccessful.
example:
TITLE: The Great Pretender (value unchanged)
TITLESORT: Great Pretender, The (value drawn from title and manipulated)

I would be grateful if anyone could provide me with an action script.
Many thanks

OK. Got it!
It may be a little inelegant but here it is:

[#0]
T=5
1=%title%
F=TITLESORT

[#1]
T=4
F=TITLESORT
1=^The (.+)
2=$1, The
3=0

[#2]
T=4
F=TITLESORT
1=^A (.+)
2=$1, A
3=0

Like that it is hardly readable which action you used and which parameter you entered.
So much I can read: you do something to TITLESORT, apparently you move the article to the end.
And there I think that this is actually over the top. I bet, that most titles are unique after the first 10 or 12 letters or to stay with the example: I do not think that there is a track called "The great pretender" and "A great pretender".
So you could simply have deleted the article in TITLESORT. The second action, where you add it again, is probably not necessary.

You're very right. Thanks