I am needing to order a list of objects based on one of its properties. I have found all kinds of answers but none order the way I need.The property I am trying to orderby is called "DrawingName".
I need the list to be ordered as follows:
"411000A","411000B","411000C","411000D","411000A","411000B","411000C","411000D"
instead I get:
"411000A","411000A","411000B","411000B","411000C","411000C","411000D","411000D"
when I use the following code.
List<DrawingData> _DrawingList = new List<DrawingData>();
_DrawingList.Add(new DrawingData() { DrawingName = "411000D", DrawingQty = 1 });
_DrawingList.Add(new DrawingData() { DrawingName = "411000D", DrawingQty = 1 });
_DrawingList.Add(new DrawingData() { DrawingName = "411000A", DrawingQty = 1 });
_DrawingList.Add(new DrawingData() { DrawingName = "411000A", DrawingQty = 1 });
_DrawingList.Add(new DrawingData() { DrawingName = "411000C", DrawingQty = 1 });
_DrawingList.Add(new DrawingData() { DrawingName = "411000C", DrawingQty = 1 });
_DrawingList.Add(new DrawingData() { DrawingName = "411000B", DrawingQty = 1 });
_DrawingList.Add(new DrawingData() { DrawingName = "411000B", DrawingQty = 1 });
_DrawingList.OrderBy(dn => dn.DrawingName);
var _DrawingListInOrder = _DrawingList.OrderBy(dwg => dwg.DrawingName);