Folosesti Bubble Sort de exemplu.E cel mai simplu.Uite un exemplu de functie care primeste ca parametru un vector si marimea lui :
void sort(int v[],int n)
{
int sortat=0;
while(!sortat)
{
sortat=1;
for(int i=1;i<n;i++)
if(v[i]>v[i+1])
{
swap(v[i],v[i+1]);
sortat=0;
}
}
}