Move the function so it isn't between the array copy and the array sort.  Seems out of place here.