I want to sort some dataframes using a specific pattern criteria. I have some columns with prefix 'Saldo' and 'Concessões' both with suffix 'Real' and 'PIB'. I want to put them in the specific order: Saldo...PIB, Concessões...PIB, Saldo...Real, Concessões...Real.
Initial column names:
Saldo...PIB | Saldo...Real | Concessões...PIB | Concessões...Real
Desired output:
Saldo...PIB | Concessões...PIB | Saldo...Real | Concessões...Real
I've tried some combinations of select() and matches() but Im not so good at regular expressions. Thanks in advance!