class Sort
{
public static void main (String[] args)
{
String[] value = {"Z","A","G","J","K" };
int arraySize= value.length;
int index , index1, index2;
String compareValue;
// The outer loop identifies each element of the array
// starting at the first and finishing at the second last element
for (index1 = 0 ; index1 < (arraySize - 1) ; index1 = index1 + 1)
{
compareValue = value[index1];
// The inner loop identifies each element of the array
// starting at one after the element idebtified by the outer loop
// and finishing at the last element
for (index2 = (index1 + 1) ; index2 < arraySize ; index2 = index2 + 1)
{
// If the inner loop element is smaller than the outer loop element
// swap the two values
if (value[index2].compareTo (compareValue)<0)
{
value[index1] = value[index2];
value[index2] = compareValue;
compareValue = value[index1];
}
}
// End of inner loop
}
// End of outer loop
// Print the results
for (index = 0 ; index < arraySize ; index = index + 1)
{
System.out.println(value[index]);
}
}
}