Rev 52 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
// Written by Ira Snyderimport java.io.*;class SortMethods {public static Object[] BubbleSort( Object[] a ) {for( int i=a.length-1; i>0; i-- )for( int j=0; j<i; j++ )if( a[j].compareTo(a[j+1]) ) arraySwap(a,j,j+1);}//SelectionSort//InsertionSort//ShellSort//MergeSort//HeapSort//QuickSortpublic static void arraySwap( Object[] a, int posA, int posB ) {Object temp = a[posB]; // temp = Ba[posB] = a[posA]; // B = Aa[posA] = temp; // A = temp}}