Simple, I have a struct like this:
struct bla{
string name;
float depth;
}
I have an bla array, and I want to sort by depth, being the
You can use the overload of Array.Sort which takes a Comparison
bla[] blas = new[] {
new bla() { name = "3", depth = 3 },
new bla() { name = "4", depth = 4 },
new bla() { name = "2", depth = 2 },
new bla() { name = "1", depth = 1 },
};
Array.Sort(blas, (x,y) => x.depth.CompareTo(y.depth));
On this way you sort the original array instead of creating new one.