You're following the same philosophy as the bubble sort, which is very, very, very slow; have you tried this?:

- Sort your unordered array with [quicksort](http://en.wikipedia.org/wiki/Quicksort). Quicksort is much faster than bubble sort (I know, you are not sorting, but the algorithm you follow is almost the same as bubble sort to traverse the array).
- Then start removing duplicates, in a for loop you could have to indexes: "source" and "destination" (on each loop you copy "source" to "destination" unless they are the same, and increment both by 1). Every time you find a duplicate you increment source (and don't perform the copy)