    #include <iostream>
    #include <algorithm>
    
    struct doPartitionOn
    {
    	int m_key;
    
    	doPartitionOn(int key) : m_key(key) {}
    
    	bool operator()(int a)
    	{
    		return (a < m_key);
    	}
    };
    
    int main()
    {
    	int arr[] = {4, 7, 3, 5, 6, 2, 9, 1, 10, 8};
    
    	for(int i = 0; i < 10; ++i)
    		std::cout << arr[i] << ' ';
    	std::cout << std::endl;
    
    	std::stable_partition(arr, arr+10, doPartitionOn(arr[0]));
    
    	for(int i = 0; i < 10; ++i)
    		std::cout << arr[i] << ' ';
    	std::cout << std::endl;
    
    	return 0;
    }
