To be clear, OrderBy
won't sort the array in place - it will return a new sequence which is a sorted copy of the array. If that's okay, then you want something like:
var sorted = array.OrderBy(item => item.Fields["FieldName"].Value);
On the other hand, I don't understand your comment that the property is returned as a string but that you can cast it to an int - you can't cast strings to ints, you have to parse them. If that's what you meant, you probably want:
var sorted = array.OrderBy(item => int.Parse(item.Fields["FieldName"].Value));
If you want that as an array, you can call ToArray()
afterwards:
var sorted = array.OrderBy(item => int.Parse(item.Fields["FieldName"].Value))
.ToArray();
Alternatively you could use Array.Sort
if you want to sort in-place, but that will be somewhat messier.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…