class BitmapSizeComparer : IComparer<ImageNode>{ public int Compare(ImageNode x, ImageNode y) { using (Bitmap bmp1 = FileIO.LoadBitmap(x.FileName)) { using (Bitmap bmp2 = FileIO.LoadBitmap(y.FileName)) { if (bmp1 != null && bmp2 != null) return -(bmp1.Width * bmp1.Height).CompareTo(bmp2.Width * bmp2.Height); } } return 0; }}
But I want to change it to sort by width and then height rather than width * height. How can I modify it to do that or would I need to sort twice?