Click here to Skip to main content
15,888,241 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I sort a 2D array? This does not seem to work

C#
for (int j = 0; j < spectrum.spectrum.GetLongLength(1); j++)
                       {
                            double mass = spectrum.spectrum[0, j];
                            double intensity = spectrum.spectrum[1, j];
                            double[] m = new double[2];
                            m[1] = mass;
                            m[0] = intensity;
                            spectrumList[j] = m;

                       }
                       double[][] orderedSpectrum = spectrumList.OrderBy(i => i[0].ToString()).ToArray();
Posted
Comments
Sergey Alexandrovich Kryukov 10-Feb-12 1:10am    
To start with, you need to define a sorting criteria and tell us this definition...
--SA

1 solution

You can also do this with datatable
sort a two-dimensional array in C#
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900