In: Computer Science
Please let me know how to make code sort.
If you put sort (sort 1000 6 5 4 3 2 1, not separate), you will get 1 2 3 4 5 6 1000.
sort 50 300 27 5
5 27 50 300
public static void main (String[] args) {
       Scanner scnr = new
Scanner(System.in);
       String a = "";
           a =
scnr.nextLine();
           String[] b =
imput.split(" ")
if (b[0].equalsI("sort")) {
}
Please do not change above code.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
// TestProg.java
import java.util.Scanner;
public class TestProg {
   public static void main(String[] args) {
       Scanner scnr = new
Scanner(System.in);
       String a = "";
       a = scnr.nextLine();
       String[] b = a.split(" ");
       String temp;
       if (b[0].equals("sort")) {
           // This Logic
will Sort the Array of elements in Ascending order
           for (int i =
1; i < b.length; i++) {
          
    for (int j = i + 1; j < b.length; j++) {
          
        int num1 =
Integer.parseInt(b[i]);
          
        int num2 =
Integer.parseInt(b[j]);
          
        if (num1 > num2) {
          
            temp =
b[i];
          
            b[i] =
b[j];
          
            b[j] =
temp;
          
        }
          
    }
           }
          
          
       }
       for(int
i=1;i<b.length;i++)
       {
          
System.out.print(b[i]+" ");
       }
   }
}
_________________________
Output:
sort 50 300 27 5
5 27 50 300
_______________Could you plz rate me well.Thank You