Sorting a String array - Algorithm
HOw can i sort a String array...
im looking for thealgorithm.
String arr[] = new String[] {"John","Amal","Peter","Cathy"};
Arrays.sort(arr);
This will give the result as -> Amal,Cathy,John,Peter
But; im looking is the actual algorithm....
how can i do it .!!!
[310 byte] By [
jugpa] at [2007-11-27 11:29:46]

public class BubbleSort {
public static void main(String[] args) {
String arr[] ={"John","Amal","Peter","Cathy"};
bubbleSort(arr);
for(int i=0; i<arr.length; i++)
System.out.println(arr[i]);
}
private static void bubbleSort(String[] array) {
String temp;
for(int i=0; i><array.length; i++) {
for(int j=0; j><array.length-1-i; j++) {
if(array[j].compareTo(array[j+1])>0) {
temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
}
}