The ascending order was displaying the same as descending order. how do i get the ascending order to be different from descending order?

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n =10;
int a[] = new int[n];
System.out.println("Enter all the elements:");
for (int i = 0; i < n; i++){
a[i] = in.nextInt();
}

for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
if (a[i] < a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.println("Descending Order:");
for (int i = 0; i < n; i++){
System.out.print(a[i]+",");
}

for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
if (a[i] > a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.println("\nAscending Order:");
for (int i = 0; i < n; i++){
System.out.print(a[i]+",");
}
}

2 answers

Which one is wrong and which one is right? This will help us focus on only the relevant code.
the ascending order is the same as descending order.
Similar Questions
  1. Order the decimals and fractions in ascending order1 19 , 1 16 , 1 312 , 0.01 , 0.062 **TIP: Use the 3 lines to click and drag
    1. answers icon 1 answer
    1. answers icon 1 answer
    1. answers icon 1 answer
  2. What is the following numbers in ascending order19/50 1.23 × 10*5 0.3 52% 1/2 These in descending order 0.762 3.2×10×-4
    1. answers icon 1 answer
more similar questions