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

Undefined qsort behavior

Hey people,

	It's a fact that we can increase performance in OpenGL by reducing
state changes, like for example, grouping primitives by material, or
texture, for example. I'd like to use the C standard lib function qsort
to do this kind of sorting for me, but it's obvious that I'll have
repeated entries in my array (more than one primitive with the same
material/texture). But the qsort man page says: "If  two  members
compare as equal, their order in the sorted array is undefined". So my
question is this: this "undefined order" still groups equal elements
together, or is the undefined *really* undefined ? For instance, if I
have an array: 4 2 3 1 2 4, do I *always* get: 1 2 2 3 4 4 ?

Thanks for your attention,
Miguel A. Osorio.