Sorting Arrays


A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most frequently used orders are numerical order and lexicographical order.[1] Most current programming languages include built-in or standard library functions for sorting arrays.


Sorting is the process through which data are arranged according to their values. The following examples show standard library and/or built-in array sorting methods for different programming languages.

Language Sort Example
C++ #include <algorithm>
sort(array, array + sizeof(array) / sizeof(int));
C# System.Array.Sort(array)
Java import java.util.Arrays;
JavaScript array.sort();
Python array.sort()
Swift array.sort()

Key Terms

Arranging data according to their values.



Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

Programming Fundamentals Copyright © 2018 by Authors and Contributors is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book