Rearranging Lists

Functions for rearranging lists.

This sorts the elements of a list into a standard order. In simple cases like this, the order is alphabetical or numerical:

Sort[{b,a,c,a,b}]

This sorts the elements, removing any duplicates:

Union[{b,a,c,a,b}]

This rotates ("shifts") the elements in the list two places to the left:

RotateLeft[{a,b,c,d,e},2]

You can rotate to the right by giving a negative displacement, or by using (RefLink[RotateRight, paclet:ref/RotateRight]):

RotateLeft[{a,b,c,d,e},-2]

Padding lists.

This pads a list with x's to make it length 10:

PadLeft[{a,b,c},10,x]