answersLogoWhite

0


Best Answer

Use a sorting algorithm. There are a bewildering number of sorting algorithms, both stable and unstable. To sort numbers, an unstable sort suffices. The algorithm you use will depend on how many numbers need to be sorted (a small or a large set), however a hybrid algorithm (a combination of two or more algorithms) can cater for both. Introsort (unstable) and timsort (stable) are the two most common hybrid sorting algorithms.

User Avatar

Wiki User

6y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Implement any sorting algorithm. Bubble sort, Quick Sort, Merge Sort etc are example of sorting algorithm.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you sort an array of numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you display 15 numbers in an ascending order using an array?

Sort the array then traverse the array, printing the element values as you go.


What does the word array mean in math?

An array is a set of numbers that form some sort of regular arrangement. A linear array is a 1-dimensional array consisting of a row or a column of a set of numbers. A 2-dimensional array is a rectangular arrangement of numbers. And there are arrays with higher dimensions. The elements of an array need not be numbers: they could be variables, functions or expressions. In other words, it's a picture to describe a multiplication problem.


How do you sort the given contents of an array?

You would sort the given elements of an array by a bubble sort or heap sort code!!


Write a java program to sort a list of numbers?

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.


When quick sort is preferred?

When you want to sort an array.


Write down programin GWBASIC to sort numbers in an array?

10 cls 20 end 30 next 40 print


Can you modify the bubble sort algorithm to search to sort an array of characters instead of array of integers?

The bubble sort algorithm can be applied to an array of characters. Every character can be translated to an integer equivalent via the ascii table


Accept 5 numbers in an array and display it?

Accept 5 numbers in an array and display it.


What is the difference between sort and asort in PHP?

sort() will order the array by its values without preserving the keys. Use it when array is indexed numerically or when you do not care about the keys. asort() will also sort the array by its values, but it will preserve the key -> value association.


What are the Application of quick sort?

Sorting an array.


Sort array in ascending descending order in python?

Using sorted(array,reverse=True)


How do you create a program that will let the user to enter 10 numbers and arrange it in ascending and descending?

#include "stdio.h" #define ARRAY_SIZE 10 void fill(float* array, int size); void spill(float* array, int size, char* delimiter); void bubble_sort(float* array, int size); void reverse(float* array, int size); void swap(float* a, float* b); int main(int argc, char* argv[]) { float numbers[ARRAY_SIZE]; fill(numbers, ARRAY_SIZE); bubble_sort(numbers, ARRAY_SIZE); spill(numbers, ARRAY_SIZE, " "); reverse(numbers, ARRAY_SIZE); spill(numbers, ARRAY_SIZE, " "); return 0; } void fill(float* array, int size) { int i = 0; while (i < size) fscanf(stdin, "%f", array + (i++)); } void spill(float* array, int size, char* delimiter) { int i = 0; while (i < size) fprintf(stdout, "%f%s", array[i++], delimiter); fputc('\n', stdout); } void bubble_sort(float* array, int size) { int i, j; for (i = 0; i < size; i++) for (j = i; j < size; j++) if (array[i] > array[j]) swap(array + i, array + j); } void reverse(float* array, int size) { int i; for (i = size / 2; i >= 0; i--) swap(array + i, array + (size - (i + 1))); } void swap(float* a, float* b) { float c = *a; *a = *b; *b = c; } fill gets the numbers from input spill sends them to output bubble sort will sort the array in ascending order reverse will reverse the list so that it is in descending order swap is used to swap two floats You can change float to double or int depending on which datatype you want to use.