Fix printing of sorted array on poping