Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Programming Fundamentals/Sorting Arrays

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Overview 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.Wikipedia: Sorting algorithm Most current programming languages include built-in or standard library functions for sorting arrays. Discussion 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. LanguageSort ExampleC++#include <algorithm>sort(array, array + sizeof(array) / sizeof(int));C#System.Array.Sort(array);Javaimport java.util.Arrays;Arrays.sort(array);JavaScriptarray.sort();Pythonarray.sort()Swiftarray.sort() LanguageReverse Sort ExampleC++#include <algorithm>sort(array, array + sizeof(array) / sizeof(int), greater <int>());C#System.Array.Sort(array);System.Array.Reverse(array);Javaimport java.util.Arrays;Arrays.sort(array, Collections.reverseOrder());JavaScriptarray.sort;array.reverse();Pythonarray.sort(reverse=True)Swiftarray.sort(>) Key Terms sorting Arranging data according to their values. References cnx.org: Programming Fundamentals – A Modular Structured Approach using C++