[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undefined qsort behavior

Tomasz Rozen wrote:
> qsort is not stable i.e. equal elements can be in any order after sorting.
> In your example you'll never know if the first '2' in the source array will
> be the first '2' or the second '2' in resulting array. (stable sorting
> preserves this order)

	Yes, I thought of that also, though I didn't write it in my original

> You will however always get correct results (equal elements grouped
> together)

	And that's exactly what matters, I only need elements grouped together,
in whatever order. I have, of course, tested this before, and I knew
equal elements were grouped, but I didn't know if that was the rule.

Thanks for your help,
Miguel A. Osorio.