I have got:
var orderedStatItmes = item.Statistics.OrderByDescending(t=>t.StartTime);
Note that
public BindingList<IStatistics> Statistics { set; get; }
What I need is the best way to reassign orderedStatItmes to item.Statistics so it should be in place.
How to do it?
Thanks!!
I can’t say I’ve used
BindingList<T>much at all myself.You may be better off sorting the underlying collection, if you’ve got access to that. Alternatively, if the
BindingList<T>itself supports sorting, you might want to useIBindingList.ApplySort.One horribly hacky way of doing it would be:
… but I wouldn’t like to say what that will do to any bindings while it’s updating.
Old answer (before question was edited to mention
BindingList<T>)Do you mean you need to mutate the existing array, or are you happy to just assign a new array reference to the
item.Statisticsproperty? If it’s the latter:If you want to basically sort the array (I’m assuming it’s an array, based on your question title) in place, you could use: