1const unsorted = ['d', 'd', 'h', 'r', 'v', 'z', 'f', 'c', 'g'];
2const sorted = unsorted.sort();
3
4console.log(sorted);
5//["c", "d", "d", "f", "g", "h", "r", "v", "z"]
6
7
8const unsortedNums = [45, 56, 3, 3, 4, 6, 7, 45, 1];
9const sortedNums = unsortedNums.sort((a, b) => {
10 return a - b;
11});
12
13console.log(sortedNums);
14//[1, 3, 3, 4, 6, 7, 45, 45, 56]
1public static void main(String args[])
2{
3 int [] array = new int[10];
4
5 array[0] = ((int)(Math.random()*100+1));
6 array[1] = ((int)(Math.random()*100+1));
7 array[2] = ((int)(Math.random()*100+1));
8 array[3] = ((int)(Math.random()*100+1));
9 array[4] = ((int)(Math.random()*100+1));
10 array[5] = ((int)(Math.random()*100+1));
11 array[6] = ((int)(Math.random()*100+1));
12 array[7] = ((int)(Math.random()*100+1));
13 array[8] = ((int)(Math.random()*100+1));
14 array[9] = ((int)(Math.random()*100+1));
15
16 System.out.println(array[0] +" " + array[1] +" " + array[2] +" " + array[3]
17 +" " + array[4] +" " + array[5]+" " + array[6]+" " + array[7]+" "
18 + array[8]+" " + array[9] );
19
20}
21