PureBasic - Sort

Overview

Sometimes, elements have to be sorted to be usable or more convenient. PureBasic offers highly optimized functions in order to sort arrays and lists, either in ascending or descending order.

SortStructuredList and SortList use Mergesort which is a stable sort, so if you first sort all the list by titles and then again by album you will get a list which is sorted by album and each album is sorted by title.
Note that this does not work with Arrays, as SortArray uses Quicksort which is unstable. (ie. the sorting of the secondary key would be lost)

Furthermore there are functions to reorder the elements of an array or a list in a random order.

Command Index

RandomizeArray
RandomizeList
SortArray
SortList
SortStructuredArray
SortStructuredList

Example

Sort_(Numeric).pb
Sort_(String).pb

Supported OS

All

Reference Manual - Index