The function stable_partition is used to change the order of the elements so that the elements meet the criteria are first in order. The relative original order is preserved.
template<class BidirectionalIterator, class Predicate> BidirectionalIterator stable_partition (BidirectionalIterator first, BidirectionalIterator last, Predicate pred);
Returns an iterator to the first position where the predicate argument is false.