I assume you want to extend the array until the sorting time exceeds 2 minutes, correct?
You simply forgot to set the
twoMinutesPassed
variable in the loop, so it remains on false. You need to do something like
if (totalTime < 120000)
arrayLength *= 1.2;
else
twoMinutesPassed = true,