why not just add numberOfSwaps in yout if statement?

if (returnArray[k] > returnArray[k + 1])
{

temp = returnArray[k + 1];

returnArray[k + 1] = returnArray[k];

returnArray[k] = temp;