-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString_array_sort.java
More file actions
38 lines (35 loc) · 979 Bytes
/
Copy pathString_array_sort.java
File metadata and controls
38 lines (35 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package zoho;
import java.util.*;
/**
*
* @author USER
*/
public class String_array_sort {
public static void main(String[] args)
{
Scanner c = new Scanner(System.in);
int n = c.nextInt();
String[] ar = new String[n];
for(int i=0;i<n;i++)
ar[i]=c.next();
for(int i=0;i<n-1;i++)
{
for(int j=i;j<n;j++)
{
if(ar[i].compareTo(ar[j])>0)
{
String temp = ar[i];
ar[i] = ar[j];
ar[j] = temp;
}
}
}
//Arrays.sort(ar);
for(String ans:ar)
System.out.print(ans+" ");
}
}