I have a slightly odd problem that I think is most likely due to an act of foolishness on my part, but for the life of me I (and other members of my team) can’t see it.
I have an object that contains a generic list property which I would like to sort. I have written a comparer class to do this for me and I am calling it in the following way:
baseObject.ListOfThings.Sort(new ThingComparer())
I have debugged into my compare function and it is returning the right values.
However After the sort call, the list remains unchanged. Have I missed something obvious, or is there something else I need to do.
Many thanks
EDIT: Yes I was being a fool, and the property returning a list was recreating it from scratch each time it was accessed. Thank you for your help everyone, and I will try to learn to check things better before asking for help in future
Is your base object recreating the list every time its accessed? Every time someone has asked me to help with this issue, that has turned out to be the problem. Maybe the property is calling a database, building the list when its accessed, etc…