public class Prog2
/* The quick sort
 */
{  public static void main(String[] as)
   {  
      
      String s = "asklcjliequwlIEHFO8weouwegho8wey";
      
      int n = s.length();
      Quick  q = new Quick(n);
      q.fillArray(s);
      q.print();
      q.quick(0, n-1);
	  System.out.println();
   }
}
   
 class Quick
 { 
 	final int MAX;
 	Comparable[] x ;
 	
 	public Quick(int n )
 	{
 		MAX = n;
 		x = new Comparable[MAX];
 	}
 	
 	public void fillArray(String s)
 	{
 		for(int j = 0; j < MAX; j++)
 		{
 			x[j] = s.charAt(j);
//due to autoboxing Charatcter wrapper class is used behind the scenes
 		}
 	}
 	
 	public void quick(int beg, int end)
 	{
 		int i = beg;
 		int j = end;
 		Comparable pivot;
 		if(i < j)//illiminates one element subarray
 		{
 			pivot = x[i];
 			while(i < j )//crossover
 			{
	 			while(x[i].compareTo(pivot) <=0  && i < end )//don't fall of array
	 			{
	 				i++;
	 			}
	 			while(x[j].compareTo(pivot) >0 )//because pivot is x[0]
	 			{
	 				j--;
	 			}
	 			if( i < j)
	 			{
	 				swap(i,j);
	 			}
	 		}			
          		swap(beg, j);
 		        quick(beg, j-1);
 		        quick(j+1, end);
 		}

 	}
 			
 	private void swap(int i, int j)
 	{
 		Comparable temp = x[i];
 		x[i] = x[j];
 		x[j] = temp;
 	}		
 			
 	public void print()
 	{
 		for(int j = 0; j < MAX; j++)
 		{
 			System.out.print(x[j]);//uses the ntoString() of the Charatcter class
 		}
 	}		
 }
   

