Wolfram Research

CanonicalListRotation

Contributed by: Ed Pegg Jr

Source Notebook

Return a canonical rotation for a list of values

ResourceFunction["CanonicalListRotation"][list]

sorts a list keeping rotationally neighboring terms as neighbors.

Details and Options

Reverse is also applied, though it can optionally be turned off.

Examples

Basic Examples

The list of items is returned as the lexicographically first rotation:

In[1]:=
ResourceFunction[
 "CanonicalListRotation"][{4, 7, 20, 10, 9, 18, 5, 1, 14, 12}]
Out[1]=
In[2]:=
ResourceFunction[
 "CanonicalListRotation"][{4, 7, 20, 10, 9, 18, 5, 1, 14, 12}, False]
Out[2]=

Scope

Six faces of a cube:

In[3]:=
face = {{1, -1, -1}, {1, -1, 1}, {1, 1, 1}, {1, 1, -1}};
Union[ResourceFunction["CanonicalListRotation"][face.#] & /@ FiniteGroupData["Octahedral", "MatrixRepresentation"]]
Out[4]=

Resource History