Sorting: Difference between revisions

From Rosetta Code
Content added Content deleted
(Added an explanation of sorting)
m (Corrected the quicksort's order)
Line 1: Line 1:
'''Sorting''' is a way of arranging a group of things in a specified order. Normally, the order is a "natural order." Examples of natural orders are counting order or alphabetical order. In computing, time and memory usage are of concern when sorting. Some algorithms are very fast, but use a lot of memory, or vice versa. Usually, speed has higher priority. The speed of an algorithm is often determined by the number of compares and/or swaps required. This is denoted as its "order" and is shown in [http://en.wikipedia.org/wiki/Big_O_notation Big O] notation. For example, a [[Quicksort]] is usually noted for being of "order n" (where n is the size of the group). This shown in Big O notation as "O(''n'')." Sorting algorithms often have different orders depending on characteristics of the group. For example, the Quicksort will perform at O(''n^2'') when the group is already ordered.
'''Sorting''' is a way of arranging a group of things in a specified order. Normally, the order is a "natural order." Examples of natural orders are counting order or alphabetical order. In computing, time and memory usage are of concern when sorting. Some algorithms are very fast, but use a lot of memory, or vice versa. Usually, speed has higher priority. The speed of an algorithm is often determined by the number of compares and/or swaps required. This is denoted as its "order" and is shown in [http://en.wikipedia.org/wiki/Big_O_notation Big O] notation. For example, a [[Quicksort]] is usually noted for being of "order n log n" (where n is the size of the group). This shown in Big O notation as "O(''n log(n)'')." Sorting algorithms often have different orders depending on characteristics of the group. For example, the Quicksort will perform at O(''n^2'') when the group is already ordered.


For complete implementations of various sorting algorithms, see [[:Category:Sorting Algorithms]].
For complete implementations of various sorting algorithms, see [[:Category:Sorting Algorithms]].

Revision as of 14:43, 21 December 2007

Sorting is a way of arranging a group of things in a specified order. Normally, the order is a "natural order." Examples of natural orders are counting order or alphabetical order. In computing, time and memory usage are of concern when sorting. Some algorithms are very fast, but use a lot of memory, or vice versa. Usually, speed has higher priority. The speed of an algorithm is often determined by the number of compares and/or swaps required. This is denoted as its "order" and is shown in Big O notation. For example, a Quicksort is usually noted for being of "order n log n" (where n is the size of the group). This shown in Big O notation as "O(n log(n))." Sorting algorithms often have different orders depending on characteristics of the group. For example, the Quicksort will perform at O(n^2) when the group is already ordered.

For complete implementations of various sorting algorithms, see Category:Sorting Algorithms.

For examples of how to use sorting functionality provided by a language, see: