Sort array of items using OrderBy<>

后端 未结 5 681
名媛妹妹
名媛妹妹 2020-12-06 16:06

I have an array of items and I would like to sort on one of their properties. I can access the items property using \"item.Fields[\"FieldName\"].Value\" the propert

5条回答
  •  失恋的感觉
    2020-12-06 16:48

    If you can use orderby it should be easy, try the following. I threw in the int.Parse although depending on how you actually want to sort this might not be required.

    var sorted = array.OrderBy(item => int.Parse(item.Fields["FieldName"].Value));
    

提交回复
热议问题