Code Below:


import java.util.*;
class Selectionsort
{
    public static void main()
    {
        Scanner s=new Scanner(System.in);
        int i,j,large,pos,temp;
        int arr[]=new int[10];
        System.out.println("Enter wt. of 10 people");
        for (i=0;i< 10;i++)
        {
            arr[i]=s.nextInt();
        }
        for(i=0;i< 9;i++)
        {
            large=arr[i];
            pos=i;
            for (j=i+1;j< 10;j++)
            {
                if(arr[j]>large)            //for ascending just change >  to  <. Rest no changes.
                {                           // descending--- >      ascending--- <
                    large=arr[j];
                    pos=j;
                }
            }
            temp=arr[i];
            arr[i]=arr[pos];
            arr[pos]=temp;
        }
        for (i=0;i<10;i++)
        {
            System.out.println(arr[i]);    
        }        
    }
}