Assuming that the function does the right thing, at the end of the function the contents of the array are in correct order. Array references are passed to functions like references, and therefore the ontents of array productID of the caller (main) will be modified by the function call.