This is bogo sort. It's order is (n-1)*n!. What it does is randomly sort the array checks to see if its sorted then if its not randomly sort it again.
public int[] BogoSort(int[] N)
{
Random rnd = new Random();
while(true)
{
boolean sorted = true;
for(int i = 0; i < N.length-1; i++)
if(N[i] > N[i+1]){
sorted = false;
break;
}
if (sorted)
return N;
for(int i = N.length - 1; i > 0; i--)
{
int rand = rnd.nextInt(i);
int temp = numbers[i];
numbers[i] = numbers[rand];
numbers[rand] = temp;
}
}
}
this is from wikipedia