answersLogoWhite

0


Best Answer

The simplest would be to put the numbers into an int[] (integer array) and pass that to java.util.Arrays.sort(int[]) (a static method), which will sort the array in ascending numerical order. Use a float[] or double[] if you need to sort non-whole numbers. You can also use the Collections.sort(List) method to sort the List directly. Or the Collections.sort(List, Comparator) if you wish to specify your own sorting criteria.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a java program to sort a list of numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

Where can you find a list of 4 digits numbers?

Write down the numbers from 1000 to 9999.


HOW TO SOLVE 'C' problem?

1. write a 'c' program to read 4(four)numbers from a file 'BANK' and calculate the average of the numbers.Now print the calculated average in another output file 'AVERAGE' 2. write a 'c' program that finds the sum and average of inputted five integer numbers of the array using dynamic memory allocation function malloc(). 3. write a 'c' program to create simple elements 1,2,3,4 in the link list of 4(four)nodes and display the list's elements. 4. write a 'c' program to convert the expression (A+B)/(C+D) into postfix expression into stack.and then evaluate it for A=10,B=20,C=15,D=5 and display the stack status after each operation. 5. write a 'c' programto create a linked list implemented on an array containing the following numbers:1,2,3,3,3,4,4,9 and pack it to remove the duplicate numbers.so that only the following data are contained by the nodes:1,2,3,4,9


What are all the four digit numbers that are divisible by five?

Any four-digit number that ends with 0, or with 5: 1000, 1005, 1010, 1015, ... 9990, 9995. If you want to have the complete list, I'll leave this fun part to you. Better write a computer program to list them.


What are all the squared numbers up to 500?

There are 22 of those. The biggest one is the square of 22, which is 484. It's easy for you to build your own list of all of them. -- Write down a list of the numbers from ' 1 ' to 22 . Then, one at a time . . . -- Multiply the number on your list by itself, and write the result next to it. -- When you finish doing that for all 22 numbers, you'll have the list of all square integers up to 500.


How do you figure the first ten perfect squares?

-- Write down a list of the first ten whole numbers. -- For each one, multiply it by itself, and write the product next to it.

Related questions

What is javadoc?

write a java program to display "Welcome Java" and list its execution steps.


Write a program for sorting for numbers without repited values?

Any number variable is extends the Number in java and it already implemented Comparable interface. So when you have a list of numbers, just use Arrays.sort().


Program for length of list in java?

Java's List interface defines the size() method, which can be used to retrieve the length of a list.


Can you write java program in Microsoft Word?

Since the Java program is basically a text file, you can write it in any text editor (although using a Java IDE, or an IDE with support for Java, does give you certain advantages). Thus, you can use programs such as NotePad or NotePad++ to write the Java program. Using word processors such as MS-Word is problematic, because these insert additional codes. You would have to make sure you save the resulting file in the text format - give the "Save As" command, and choose a text format from the list.


How do you write a program which reads a list of ten numbers and print the list in reserve order in c program?

The simplest way is probably to read the numbers into an array and then prints each element of the array starting at the last one and moving backwards.


A Java Program to choose directory and search file name content file name and content must both enter It will list out the result and when click on the result it will show the content?

write a program of phone dirictory


How can one assign a list of integers in Java?

Put statements at the start of ones code will allow one to have a list of integers in their Java program. If one does this then they will successfully have integers in their code.


Simple java program to find even numbers?

Here is a simple program that will list all the even numbers between 1 and 50: public class EvenNumbers { public static void main(String[] args) { for(int i=1; i<=50; i++) { if(i%2 ==0) { System.out.println(i); } } } }


How do you sort numbers in Java program?

Here's simple example to sort numbers in Java using a List: import java.util.ArrayList; import java.util.Collections; import java.util.List; public class SortTest { public static void main (String[] args) { List<Integer> list = new ArrayList<Integer>(); list.add(100); list.add(1); list.add(24); list.add(3); System.out.println(list); Collections.sort(list); System.out.println(list); } } Running it generates the following output: [100, 1, 24, 3] [1, 3, 24, 100]


How do you write a Java program to implement weighted queue using circular doubly linked list?

Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.


How to write aC program to merge two singly linked list?

write a c program to circular queue


How do you write a program that reads 20 bytes of data and starts at address 8000H i need to create a list of numbers and have the program store the list and retreive it in reverse?

This seems to be two separate homework assignments merged together. You should ask them separately.