void sort( int values[ ] , int n)
{
// TODO: implement an O(n^2) sorting algorithm
int sorted = 0 ;
while ( sorted < n+ 1 )
{
for ( int i = 0 ; i < n; i++ )
{
if ( values[ i] > values[ i+ 1 ] )
{
int change;
change = values[ i] ;
values[ i] = values[ i+ 1 ] ;
values[ i+ 1 ] = change;
sorted = 0 ;
}
else
{
sorted++;
}
}
}
return ;
}
dm9pZCBzb3J0KGludCB2YWx1ZXNbXSwgaW50IG4pCnsKICAgIC8vIFRPRE86IGltcGxlbWVudCBhbiBPKG5eMikgc29ydGluZyBhbGdvcml0aG0KICAgIGludCBzb3J0ZWQgPSAwOwogICAgd2hpbGUgKHNvcnRlZCA8IG4rMSkKICAgIHsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykKICAgICAgICB7CiAgICAgICAgCiAgICAgICAgICAgIGlmICh2YWx1ZXNbaV0gPiB2YWx1ZXNbaSsxXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaW50IGNoYW5nZTsKICAgICAgICAgICAgICAgIGNoYW5nZSA9IHZhbHVlc1tpXTsKICAgICAgICAgICAgICAgIHZhbHVlc1tpXSA9IHZhbHVlc1tpKzFdOwogICAgICAgICAgICAgICAgdmFsdWVzW2krMV0gPSBjaGFuZ2U7CiAgICAgICAgICAgICAgICBzb3J0ZWQgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc29ydGVkKys7CiAgICAgICAgICAgIH0KICAgICAgICB9ICAgCiAgICB9CiAgICAKICAgIHJldHVybjsKfQ==