Sort

Sort

program to sort a list of numbers in decendimg order

View Answers

December 7, 2010 at 10:50 AM

Hi Friend,

Try the following code:

import java.util.*;
class SortListInDescendingOrder{
    public static void main(String[] args) 
    {
        ArrayList<Integer> list=new ArrayList<Integer>();
        list.add(5);
        list.add(2);
        list.add(6);
        list.add(1);
        list.add(3);
        list.add(4);
        Collections.sort(list,Collections.reverseOrder());
        for(int i=0;i<list.size();i++){
            System.out.println(list.get(i));
        }

    }
}

Thanks









Related Tutorials/Questions & Answers:
Sort
Sort  program to sort a list of numbers in decendimg order   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import java.util.*; class SortListInDescendingOrder{ public static void main(String[] args
Array sort
Array sort  Program that uses a function to sort an array of integers
Advertisements
bubble sort
bubble sort  write a program in java using bubble sort
insertion sort
insertion sort  write a program in java using insertion sort
insertion sort
insertion sort  write a program in java using insertion sort
insertion sort
insertion sort  write a program in java using insertion sort
insertion sort
insertion sort  how many arrays needed for insertion sort and why
bubble sort
bubble sort  how to calculate the number of passes in bubble sort
insertion sort
insertion sort  write a program in java using insertion sort
buble sort
buble sort  ascending order by using Bubble sort programm   Java BubbleSort Example
SEARCH AND SORT
SEARCH AND SORT  Cam any one provide me the code in java that : Program to search for MAX,MIN and then SORT the set using any of the Divide and conquer method
Sort
quick sort
; System.out.println(" Quick Sort\n\n"); System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++){ array[i...("Values after the sort:\n"); for(i = 0; i <array.length; i
quick sort
; System.out.println(" Quick Sort\n\n"); System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++){ array[i...("Values after the sort:\n"); for(i = 0; i <array.length; i
quick sort
; System.out.println(" Quick Sort\n\n"); System.out.println("Values Before the sort:\n"); for(i = 0; i < array.length; i++){ array[i...("Values after the sort:\n"); for(i = 0; i <array.length; i
php array sort by field
php array sort by field  Array sort by field in PHP
php array sort functions
php array sort functions  Sort function in php
php array sort by key
php array sort by key  php script to sort array by key
php array sort by value
php array sort by value  an example to sort the array by value
Insertion Sort Applet
Insertion Sort Applet  Please All , I need Insertion sort applet program
Insertion Sort Applet
Insertion Sort Applet  I need Insertion Sort Applet code was design by Dr. Daniel Liang Please
insertion sort applet code
insertion sort applet code  i need Insertion Sort Applet Program
ModuleNotFoundError: No module named 'sort'
ModuleNotFoundError: No module named 'sort'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'sort' How to remove the ModuleNotFoundError: No module named 'sort' error
string array sort
string array sort  Hi. How to sort a string array
string array sort
string array sort  Hi. How to sort a string array
string array sort
string array sort  Hi. How to sort a string array
string array sort
string array sort  Hi. How to sort a string array
string array sort
string array sort  Hi. How to sort a string array
sort function - JSP-Servlet
sort function  How to sort a string variable in java   Hi friend, Please give in details and full source code to solve the problem. For information on java visit to : http://www.roseindia.net/java
Insertion Sort Timer
Insertion Sort Timer  Welcome all I wanna program in java find the timer of insertion sort and find time complexity for random value thanks all
visualization Max-Heap-sort
visualization Max-Heap-sort  To Whom It May Concern, Would you please give the source code of applet Max-heap sort? I want to see the visualization of Max-Heap sort. Best Regards, saeideh
bubble sort - Java Beginners
bubble sort  how to write program The bubble-sort algorithm in double...  Hi friend, Bubble Sort program : public class...[] = {10,5,3,89,110,120,1,8,2,12}; System.out.println("Values Before the sort:\n
Help With Costructing Selection sort?
Help With Costructing Selection sort?  Using a selection sort, for each entry in the array, display the original index of the first dimension... in advance!   Please visit the following link: Java Selection Sort
sort dict by value python
sort dict by value python  Hi, Is is possible to sort dict by value...++":3, "Spring":2, "PHP":3} I want to sort this dictionary. How to sort... of key value pairs, but you can sort the dictionary. I have created sample
How to sort the rows in SQL?
How to sort the rows in SQL?  How to sort the rows in SQL?   Hi, Here is the answer,ADS_TO_REPLACE_1 The ORDER BY clause allows you to sort the records in your result set. The ORDER BY clause can only be used
Java insertion sort question
Java insertion sort question  I've got another program that I need help with. I am trying to write a Java method that accepts an array of strings, and sorts the strings using the insertion sort algorithm. Then I need to write
Heap Sort in Java
Heap Sort in Java is used to sort integer values of an array. Like quicksort, insertion sort, bubble sort and other sorting methods, heap sort is used to sort an unsorted list. When compared to other sorting methods heap sort
Insertion Sort - Java Beginners
you help me.What is the code for Insertion Sort and Selection Sort that displays...: public class InsertionSort { public static void sort(String[] array) { int...) { String[] array ={"S","D", "A","B","Z", "M","O", "L","H", "Y"}; sort
Java Dictionary-Sort,Extract
Java Dictionary-Sort,Extract  *I need to make an English(other language) dictionary by collecting english/other language words in a text file;then using that text file I need to sort the words collected in alphabetical order
Merge Sort Java
Merge Sort in Java is used to sort integer values of an array. There are many methods to sort Java like bubble sort, insertion sort, selection sort, etc. In Merge sort unsorted values are divided into two equal parts
sort java - Java Beginners
sort java  1. A statistics company wants to keep information of families. The information of a family is the family name, the number of members and first name of each member. The families are sorted alphabetically by family name
search and sort techniques in java
search and sort techniques in java  Hi i attened an interview recently... they asked to write all searching and sorting technique codes in java.. i said i would use collection frame work for it.. but they dosnt want me to use
Insertion Sort In Java
Insertion Sort In Java     ... In this example we are going to sort integer values of an array using insertion sort. Insertion sorting algorithm is similar to bubble sort. But insertion sort
Version of com.htyleo>external-sort dependency
List of Version of com.htyleo>external-sort dependency
ModuleNotFoundError: No module named 'cn-sort'
ModuleNotFoundError: No module named 'cn-sort'  Hi, My Python...-sort' How to remove the ModuleNotFoundError: No module named 'cn-sort... to install padas library. You can install cn-sort python with following command
ModuleNotFoundError: No module named 'colour-sort'
ModuleNotFoundError: No module named 'colour-sort'  Hi, My Python... 'colour-sort' How to remove the ModuleNotFoundError: No module named 'colour-sort' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'czech-sort'
ModuleNotFoundError: No module named 'czech-sort'  Hi, My Python... 'czech-sort' How to remove the ModuleNotFoundError: No module named 'czech-sort' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'json-sort'
ModuleNotFoundError: No module named 'json-sort'  Hi, My Python... 'json-sort' How to remove the ModuleNotFoundError: No module named 'json-sort' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'mih-sort'
ModuleNotFoundError: No module named 'mih-sort'  Hi, My Python...-sort' How to remove the ModuleNotFoundError: No module named 'mih-sort... to install padas library. You can install mih-sort python with following
ModuleNotFoundError: No module named 'nxpy-sort'
ModuleNotFoundError: No module named 'nxpy-sort'  Hi, My Python... 'nxpy-sort' How to remove the ModuleNotFoundError: No module named 'nxpy-sort' error? Thanks   Hi, In your python environment you

Ads