in reply to Understanding how sort uniq works

It didn't sort uniq the array and I didn't understand why.

It sorted the unique values of the array. You simply didn't save the sorted values anywhere.