Then you iterate in the sorted array and delete every pointers except if the pointer you're at is the same one you juste deleted. It keeps you from having two imbricated loops which is n^2 of complexity.
Something like that:
Item* Array[ARRAYSIZE];SortFunction( Array );Item* p = 0;for( int i = 0; i < ARRAYSIZE; ++i ){ if( Array != p ) { p = Array; delete Array; }}
If you use a convenable sorting algorithm, you will have n*log(n) of complexity which is better than n^2 for an array of any size. ( Ok, its actually n*lg(n) plus n plus a constant, but it is still very much better than n^2! )
[Edited by - rikibee on July 4, 2006 4:46:27 PM]