I need your help by sorting a text file with the following input:
id scalar2_q1p2_114(-2,-1) =
+ 0
;
id scalar2_q1p2_114(-2,-2) =
+ 0
;
id scalar2_q1p2_114(-2,0) =
+ 0
;
id scalar2_q1p2_114(-2,1) =
+ 0
;
id scalar2_q1p2_114(-2,2) =
+ 0
;
id scalar2_q1p2_114(-1,-2) =
+ 0
;
id scalar2_q1p2_114(-1,-1) =
+ 0
;
id scalar2_q1p2_114(-1,0) =
+ 0
;
id scalar2_q1p2_114(-1,1) =
+ 0
;
id scalar2_q1p2_114(-1,2) =
+ 0
;
id scalar2_q1p2_114(0,-2) =
+ 0
;
id scalar2_q1p2_114(0,-1) =
+ 0
;
id scalar2_q1p2_114(0,0) =
+ 0
;
id scalar2_q1p2_114(0,1) =
+ 0
;
id scalar2_q1p2_114(0,2) =
+ 0
;
id scalar2_q1p2_114(1,-2) =
+ 0
;
id scalar2_q1p2_114(1,-1) =
+ 0
;
id scalar2_q1p2_114(1,0) =
+ 0
;
id scalar2_q1p2_114(2,-2) =
+ 0
;
id scalar2_q1p2_114(2,-1) =
+ 0
;
id scalar2_q1p2_114(2,0) =
+ 0
;
id scalar2_q1p2_114(1,2) =
+ scalar2_q1p2_114(1,1)*((-d+3)*den(p22))
;
id scalar2_q1p2_114(2,1) =
+ scalar2_q1p2_114(1,1)*((-d+3)*den(p22))
;
id scalar2_q1p2_114(2,2) =
+ scalar2_q1p2_114(1,1)*((d^2-9*d+18)*den(p22^2))
;
I want to open the text file and order the argument by the rule (-2,-2)->(-2,-1)->(-2,0)...(2,2)
For this example the first element and second element should be swap but i want a general programm to do this for any position of the arguments.
Can somebody help me out with this.
It is similar to this question: Alphanumeric sorting in Python and negative numbers
But only that my string is a little more complicated