Give an O(n) algorithm which takes as input an array S, then divides S into three sets: negatives, zeros, and positives. Show how to implement this in place, that is, without a
The C++ library has a stable_partition algorithm which requires n comparisons and O(n log n) swaps when it runs in-place.
As @Ted points out, the problem requires two applications of this algorithm.