private bool SortByZ()
{
//using InsertionSort because it's stable (meaning equal values keep the same order)
//this is unlike List.Sort, which is unstable, so things would constantly shift if equal.
_childNodes.InsertionSort(ZComparison);
//check if the order has changed, and if it has, update the quads/depth order
//http://stackoverflow.com/questions/3030759/arrays-lists-and-computing-hashvalues-vb-c
int hash = 269;
unchecked //don't throw int overflow exceptions
{
int childCount = _childNodes.Count;
for(int c = 0; c<childCount; c++)
{
hash = (hash * 17) + _childNodes[c].GetHashCode();
}
}
if(hash != _oldChildNodesHash)
{
_oldChildNodesHash = hash;
return true; //order has changed
}
return false; //order hasn't changed
}