For your edu-tainment, I present, BOGOSORT!
(Implemented (badly) in Java for extra points!)
import java.util.Random;
public class Bogosort {
public static void main(String[] args) {
int[] sort={5,7,3,9};
boolean[] flag=new boolean[sort.length];
int[] sorted=new int[sort.length];
Random gen=new Random();
boolean done=false;
int choice=gen.nextInt(sort.length);
while(!done) {
for(int n=0; n<flag.length; n++) {
flag[n]=false;
}
for(int i=0; i<sort.length; i++) {
while(flag[choice]==true) {
choice=gen.nextInt(sort.length);
}
flag[choice]=true;
sorted[i]=sort[choice];
}
int last=sorted[0];
for(int a=0; a<sort.length; a++) {
if(sorted[a]>=last) {
done=true;
last=sorted[a];
} else {
done=false;
break;
}
}
}
for(int b=0; b<sort.length; b++) {
System.out.println(sorted[b]);
}
}
}
Oh... you said efficient?
Erm... Well, technically speaking, in the best case it'll do O(n)!
....
Nevermind.
:p