I have an array of structures. The structure of my structs is this:
[StructLayout(LayoutKind.Sequential)]
public struct TOCRRESULTSHEADER
{
public int StructId;
public int XPixelsPerInch;
public int YPixelsPerInch;
public int NumItems;
public float MeanConfidence;
}
[StructLayout(LayoutKind.Sequential)]
public struct TOCRRESULTSITEM
{
public short StructId;
public short OCRCha;
public float Confidence;
public short X;
public short Y;
public short Width;
public short Height;
}
[StructLayout(LayoutKind.Sequential)]
public struct TOCRRESULTS
{
public TOCRRESULTSHEADER Hdr;
public TOCRRESULTSITEM[] Item;
}
I am populating a structure of type TOCRRESULTS like this:
TOCRRESULTS MyArray = GetOCRForImage(filename);
I am sorting the array by the Y values just fine using this:
Array.Sort<TOCRRESULTSITEM>(MyArray.Item, (a,b) => a.Y.CompareTo(b.Y));
Is there a way to sort by Y and X without having to write my own sorting routine?
I tried using LINQ:
var newarray = OCRLetterArray.Item.OrderBy(x => x.Y).ThenBy(x => x.X).ToArray();
but it never sorted my array.
I apologize for the drastic change from my original posting. I was hoping I could get away with a simple example.