I have list of associations like this:
er={<|A->{d11,{"1b1","2b1","3a1"}},B->{d12,{"1a1","2a1","3b1"}},C->{d13,{"1c1","2c1","3c1"}}|>,
<|A->{d21,{"1b2","2b2","3a2"}},B->{d22,{"1a2","2a2","3b2"}},C->{d23,{"1c2","2c2","3c2"}}|>,
<|A->{d31,{"1b3","2b3","3a3"}},B->{d32,{"1a3","2a3","3b3"}},C->{d33,{"1c3","2c3","3c3"}}|>,
<|A->{d41,{"1a4","2a4","3a4"}},B->{d42,{"1b4","2b4","3b4"}},C->{d43,{"1c4","2c4","3c4"}}|>,
<|A->{d51,{"1a5","2a5","3a5"}},B->{d52,{"1b5","2b5","3b5"}},C->{d53,{"1c5","2c5","3c5"}}|>}
I want to swap data between rules A and B and to only on [[2]][[;; 2]]
their parts/levels, eg. in A
"1b1","2b1"
should be "1a1","2a1"
, and in B
"1a1", "2a1"
should be "1b1","2b1"
,...and the same procedure for only next two associations, 3 in total).
So, the resulting, corrected list of associations would be:
ok={<|A->{d11,{"1a1","2a1","3a1"}},B->{d12,{"1b1","2b1","3b1"}},C->{d13,{"1c1","2c1","3c1"}}|>,
<|A->{d21,{"1a2","2a2","3a2"}},B->{d22,{"1b2","2b2","3b2"}},C->{d23,{"1c2","2c2","3c2"}}|>,
<|A->{d31,{"1a3","2a3","3a3"}},B->{d32,{"1b3","2b3","3b3"}},C->{d33,{"1c3","2c3","3c3"}}|>,
<|A->{d41,{"1a4","2a4","3a4"}},B->{d42,{"1b4","2b4","3b4"}},C->{d43,{"1c4","2c4","3c4"}}|>,
<|A->{d51,{"1a5","2a5","3a5"}},B->{d52,{"1b5","2b5","3b5"}},C->{d53,{"1c5","2c5","3c5"}}|>}
Please help with composing procedure to rearrange wrong to correct associations.
EDIT: none of the values are fixed and are not known in advance, they are arbitrary numbers. a
s, b
s and c
s are used only for exposure and to avoid mess. Only keys (A, B C) are fixed and known in advance.
C
is a built-in symbol. $\endgroup$