1public static void insertion(String[] ans){ //Main Methord
2 for (int i = 0; i < ans.length-1; i++) {
3 for (int j = i + 1; j > 0; j--) {
4 if (ans[j].compareTo(ans[j - 1]) < 0) {
5 String temp = ans[j];
6 ans[j] = ans[j - 1];
7 ans[j - 1] = temp;
8 }
9 }
10 }
11 }
12public static void main(String[] args){ //driver code
13 String[] ans = {"xa","ax"};
14 insertion(ans);
15}