Skip to content
Property Value
Hex Value $E3
Categories
Localizations
  • FR: Tricroi(

SortA(

Overview

Sorts elements of listname in ascending order.

Availability: Token available everywhere.

Syntax

SortA(listname)

Arguments

NameTypeOptional
listnamelist

Location

2nd, list, OPS, 1:SortA(


Overview

Sorts elements of keylistname in ascending order, then sorts each dependlist as a dependent list.

Availability: Token available everywhere.

Syntax

SortA(keylistname,dependlist1[,dependlist2,...,dependlist n])

Arguments

NameTypeOptional
keylistnamelist
dependlist1list
dependlist2listYes
dependlist nlistYes

Location

2nd, list, OPS, 1:SortA(


Description

The SortA( command sorts a list in ascending order. It does not return it, but instead edits the original list variable (so it takes only list variables as arguments).

SortA( can also be passed multiple lists. In this case, it will sort the first list, and reorder the others so that elements which had the same indices initially will continue having the same indices. For example, suppose the X and Y coordinates of some points were stored in ʟX and ʟY, so that the Nth point had coordinates ʟX(N) and ʟY(N). Then SortA(ʟX,ʟY) would sort the points by their x-coordinates, still preserving the same points.

However, SortA( is not stable: if several elements in the first list are equal, then the corresponding elements in the subsequent lists may still end up being in a different order than they were initially.

Algorithm

The algorithm used by SortA( and SortD( appears to be a modified selection sort. It is still O(n2) on all inputs, but for some reason takes twice as long on a list with all equal elements. It is not stable.


Source: parts of this page were written by the following TI|BD contributors: DarkerLine, GoVegan.

History

Calculator OS Version Description
TI-82 1.0 Added

Last update: September 30, 2023 15:38:51
Created: February 23, 2023 23:15:01
Authors: Adrien Bertrand