I am trying to sort a listview and then remove redundant items. But neither the items are sorted properly nor the redundancies are removed completely. Please help..
lvwMessages.Sorting = SortOrder.Descending;
for (int i = 0; i < lvwMessages.Items.Count - 1; i++)
{
if (lvwMessages.Items[i].Tag == lvwMessages.Items[i + 1].Tag)
lvwMessages.Items[i + 1].Remove();
}

You are changing the collection as you are iterating it. That always has some funny side-effects.
E.G. Let’s say you have five items with ids and tags, respectively,
First time through the loop, i = 0, and the Items collection has 5 elements.
ID0 is compared with ID1, and ID1 is removed.
Next time through the loop, i=1, and the Items collection has 4 elements.
Now, instead of comparing ID0 with ID2, ID2 is compared with ID3, and nothing is removed, etc…
You could use something like this:
incrementing the counter only if you have not removed an item.