Create a new list, iterate through your matrix and add all the values to the list, then call list.Sort()
List<int> pixelValues = new List<int>();
Best I can come up with using the provided information. You'll want to replace int with whatever type you're storing in your matrix, and I'm not sure what the matrix's structure looks like but I'm guessing you know how to iterate through it.
If you need something other than the default comparison there are overloads of Sort available, see the MSDN page for List