Here is some pseudocode in my own made-up language:
function f(array a)
array newArray
while a.size() == 0
int position = randomNumber(1 to a.size())
int removedNumber = a[position]
a.remove(position)
newArray.insertAtEnd(removedNumber)
end while
return newArray