public void SortZInsertionAscending() { if (Count == 1 || Count == 0) return; int whereObjectBelongs; for (int i = 1; i < Count; i++) { if ((this[i]).Position.Z < (this[i - 1]).Position.Z) { if (i == 1) { Insert(0, this[i]); base.RemoveAtOneWay(i + 1); continue; } for (whereObjectBelongs = i - 2; whereObjectBelongs > -1; whereObjectBelongs--) { if ((this[i]).Position.Z >= (this[whereObjectBelongs]).Position.Z) { Insert(whereObjectBelongs + 1, this[i]); base.RemoveAtOneWay(i + 1); break; } else if (whereObjectBelongs == 0 && (this[i]).Position.Z < (this[0]).Position.Z) { Insert(0, this[i]); base.RemoveAtOneWay(i + 1); break; } } } } }