Sort was working filling in the array had an error in the for loop.