   how would I sort objects like this?
  I've got a struct with a z value, and bool telling wether it has transparency, and a pointer to a texture. I want to sort it so all the non transparents are at the begining of the list and all the textures are grouped together then sort those grouping by z order.would it be something like this.operator &lt; (const MyStruct& struct2){    if (struct2.alpha == false && struct1.alpha == true)    {    return true;    }    else if ( /* compare texture pointers not sure on this */ )    {   return true;    }    else   return struct1.z &lt; struct2.z;}mainly i just want to know is that the way I would compare the alpha values to make it so the non transparent textures end up at the begining of the list? Also how exactly would I compare a pointer so that thy get grouped together? would doing*ptr1 < *ptr2would that work?[/source]   
Quote:Original post by freeworldall the textures are grouped togetherDo textures have some property by which they are ordered, or does the order not matter? In the latter case:bool operator<(const MyStruct& x, const MyStruct& y){    if (y.alpha < x.alpha) return true;    if (x.alpha < y.alpha) return false;    if (x.texture < y.texture) return true;    if (y.texture < x.texture) return false;    return x.z < y.z;};Quote:Original post by DevFredQuote:Original post by freeworldall the textures are grouped togetherDo textures have some property by which they are ordered, or does the order not matter? no the order of textures doesn't matter, just that are grouped together, and was really just an idea I wanted to test. Would that work with pointers? or should I assign an unique id to each texture which would be too much of a hassle?;Quote:Original post by freeworldno the order of textures doesn't matterThen comparing the pointers themselves as in my example should work.   ;Quote:Original post by DevFredQuote:Original post by freeworldno the order of textures doesn't matterThen comparing the pointers themselves as in my example should work.It probably *will* work, but it is not true that it *should*. I believe using <, <=, >= or > to compare two pointers that are not pointing to the same array (or right after it) is undefined behavior in both C and C++.   