Explicitly sort the added local variables

Fixes random CI failures because it would not be defined ordering wise.
This makes sure we always set up the locals in order they were defined
on the regular expression.