Home

Sorted

Sorted is an adjective describing a sequence or collection whose elements are arranged according to a defined order. Common orders are numeric ascending or descending and lexicographic (dictionary) order, but any criterion defined by a comparator may be used. A sorted sequence is easy to search and compare.

In computing, sorting arranges data to enable efficient operations such as binary search, merging, deduplication, and

Algorithms used to produce sorted data vary in speed and resource use. Efficient general-purpose sorts include

In programming languages, functions or methods named sort or sorted return data in a sorted order. For

Applications include data preprocessing, database indexing, report generation, and streaming or external sorting where data exceeds

See also: Sorting algorithm, Stable sort, Comparison sort.

reporting.
Sorting
can
be
performed
on
lists,
arrays,
records,
or
streams.
Sorting
can
be
stable
or
unstable:
stable
sorts
preserve
the
relative
order
of
equal
elements;
unstable
sorts
may
not.
quicksort,
mergesort,
and
heapsort,
typically
averaging
O(n
log
n)
time.
Some
sorts,
such
as
insertion
sort
or
bubble
sort,
are
simple
but
less
scalable.
Sorting
may
be
in-place
or
require
additional
memory,
and
may
be
stable
or
unstable.
example,
Python
offers
the
built-in
sorted(iterable,
key=None,
reverse=False)
that
returns
a
new
list,
and
the
list.sort()
method
that
sorts
the
list
in
place;
Java
and
C++
offer
sort
routines
in
standard
libraries;
many
SQL
dialects
use
ORDER
BY
to
sort
results.
A
key
function
or
comparator
can
steer
the
sorting
order,
and
reverse
or
descending
options
are
common.
memory.