# What is the probability that all priorities are unique for Permute-By-Sorting algorithm?

I hope someone can help me answer the following question. Thanks!

Here is a pseudo code of Permute-By-Sorting algorithm:

Permute-By-Sorting (A)

    n = A.length

let P[1..n] be a new array

for i = 1 to n

P[i] = Random (1,n^3)

sort A, using P as sort keys


In the above algorithm, the array P represents the priorities of the elements in array A. Line 4 chooses a random number between 1 and n^3.

The question is what is the probability that all priorities in P are unique? and how do I get the probability?

-