a mild sorting annoyance?
a mild sorting annoyance?
- Subject: a mild sorting annoyance?
- From: Steve Mykytyn <email@hidden>
- Date: Mon, 18 Nov 2002 15:22:17 -0800
The sorting methods available for NSMutableArray (e.g
sortUsingFunction) do not appear to be "stable" - that is, they don't
preserve the previous order of elements with identical values after a
sort. The documentation does not say, and the list archive does not
appear to have touched on this issue.
This would be of value, for example, if you had a list of all cities
and towns in the USA and wanted to sort it by city name, but if there
were two cities with the same name, you would want them in order by
state. If the sort were stable, you could simply sort first by state,
then by city name and you would be OK. This does not appear to be the
case with NSMutableArray - you would have to decide by evaluating both
city name and state yourself.
Having a stable sort makes life easier in some situations...
Is this worth a bug report? Or did i miss something here???
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.