It looks like that you are required to write a sort function in which you will swap neighbour elements if the first one is greater than the second one.
EDIT: or you are required to use std::next_permutation.
For example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <algorihm>
#include <iterator>
int main()
{
int a[] = { 2, 3, 1, 4 };
for ( int x : a ) std::cout << x << ' ';
std::cout << std::endl;
while ( std::next_permutation( std::begin( a ), std::end( a ) ) );
for ( int x : a ) std::cout << x << ' ';
std::cout << std::endl;
}