import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static int partition(int[] arr,int low,int high){
int i=low,j=high;
while (i<j) {
while (arr[i]<=arr[low] && i<=high-1) {
i++;
}
while (arr[j]>arr[low] && j>=1) {
j--;
}
if(i<j){
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
int t1=arr[low];
arr[low]=arr[j];
arr[j]=t1;
return j;
}
public static void quick_sort(int[] arr,int low,int high){
if(low<high){
int j=partition(arr,low,high);
quick_sort(arr,low,j-1);
quick_sort(arr,j+1,high);
}
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}
quick_sort(arr,0,n-1);
for(int i=0;i<n;i++){
System.out.println(arr[i]);
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: