there are several sorting methods, I suggest you to start with thesimplest, just named "Simple Sort".You can find explanation, source and a nice demo herewww.cs.brockport.edu/.../simplesort.html