# How to sort eigenvalues from lowest to highest ? And how to extract the corresponding eigenvector

K={{2.99889*10^6,2.57571*10^6,54.9546,285048.,1.37129*10^6,-4.3079*10^6},{2.57571*10^6,2.99893*10^6,131.169,-285052.,1.3713*10^6,-4.30792*10^6},{54.9546,131.169,3.42441*10^7,-4.76309,-113.584,-24.2506},{285048.,-285052.,-4.76309,429098.,4.45647,-2.74554*10^-10},{1.37129*10^6,1.3713*10^6,-113.584,4.45647,4.25528*10^7,-4.2688*10^6},{-4.3079*10^6,-4.30792*10^6,-24.2506,-2.74554*10^-10,-4.2688*10^6,6.77063*10^6}};
M={{44.649,-2.19291,0.000269222,35.2629,20.3676,-33.3301},{-2.19291,44.6498,-0.000556479,-35.2635,20.3682,-33.3301},{0.000269222,-0.000556479,52.3332,0.0001103,-0.000168249,0.000148546},{35.2629,-35.2635,0.0001103,53.1009,-0.000193321,0},{20.3676,20.3682,-0.000168249,-0.000193321,39.598,-32.9862},{-33.3301,-33.3301,0.000148546,0,-32.9862,52.3816}}
{val,vec}=Eigensystem[{K,M}]


Always I have to sort the results manually it is very tedious . Is there any other way to carry out this with out using revers function.

The answer, so far as I can tell, is the Reverse function:

Reverse[vec]
Reverse[val]


Alternately, if you want to extract the $$n$$th smallest eigenvalue and the $$n$$th smallest eigenvector, you can use

First[Eigenvectors[{K, M}, -n]]
First[Eigenvalues[{K, M}, -n]]


All of this assumes that by "largest" and "smallest", you mean largest & smallest by absolute value. If all of the eigenvalues are known to be positive, then these are the same thing. (I assume from your notation that you're doing a normal mode problem, in which case all the eigenvalues should be positive if the system is stable.)

Eigensystem orders eigenvalues and eigenvectors in decending order with respect to absolute value. So Reverse is not always the right answer. But you may employ Ordering:

SeedRandom[1];
A = # + #\[Transpose] &@RandomReal[{-1, 1}, {6, 6}];
B = #.#\[Transpose] &@RandomReal[{-1, 1}, {6, 6}];
{val, vec} = Eigensystem[{A,B}];
i = Ordering[val]
{val[[i]], vec[[i]]}


{2, 3, 5, 6, 4, 1}

• SeedRandom[1]; {val, vec} = Eigensystem[# + #[Transpose] &@{K, M}] i = Ordering[val] {val[[i]], vec[[i]]} – acoustics Oct 25 '18 at 5:39
• I Tried this but its in not working – acoustics Oct 25 '18 at 5:40
• Then try SeedRandom[1]; {val, vec} = Eigensystem[{K, M}]; i = Ordering[val]; {val[[i]], vec[[i]]}. I used # + #[Transpose] &@ only to obtain a symmetric, indefinite matrix. – Henrik Schumacher Oct 25 '18 at 5:50