I have a ListView that I need to update by adding an item. Using .Add() will place it on the bottom. So I can then sort it by a insert time (it’s one of the fields). Another option is to use Collection.Insert(0, newItem) that will put it to the top and move everything down one index.
Read somewhere that Collection.Insert(0, newItem) may be slow for larger lists b/c of the shifting.
If that is the case – what would be faster? Collection or Add + Sort?
or is there another way?
Thanks.
Insert will be faster than Add + Sort, because Sorting will involve unnecessary comparisons if your list is already sorted. But like others have said, it probably won’t matter enough to care.