How to put the variable in a certain order after using “Solve[]”

I have this code:

eq1 = 4 x1 + 5 x2 - 9 x11 == 5;
eq2 = 5 x1 - 3 x2 + 3 x11 == 99;
eq3 = 2 x1 + 5 x2 - 4 x11 == 7;
system = {eq1, eq2, eq3};
solution = Solve[system]


and the output is:

{{x1 -> 2574/161, x11 -> 1094/161, x2 -> 71/161}}


I would like the output to go in order i.e. x1, x2, and then x11, but I cannot figure out how.

• Use x[1],x[2],x[1,1] (or x[1],x[2],x[11]) instead of x1,x2,x11. – AccidentalFourierTransform Nov 13 '18 at 2:17
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Chris K Nov 13 '18 at 2:39
• BTW, you can even suppress the output of x11 by using Solve[system, {x1, x2}, {x11}], if you want to. – Αλέξανδρος Ζεγγ Nov 13 '18 at 7:06

Solve will return the solutions in the order requested:

solution = Solve[system, {x1, x2, x11}]
(*  {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}  *)

• Thank you so much! – Jose Castellanos Nov 13 '18 at 14:13
SortBy[#, {StringLength @ SymbolName[#[[1]]] &}] & /@ solution


{{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}

Try also this:

solution /. {a_, b_, c_} -> {a, c, b}

(*  {{x1 -> 2574/161, x2 -> 71/161, x11 -> 1094/161}}   *)


Have fun!