Rearranging & Restructuring Lists

The Wolfram Language encapsulates in a small number of functions vast flexibility in rearranging lists with any structure and any number of elements.

Flatten flatten out any sequence of levels in a nested list

Partition partition lists or nested lists into sublists

Join join lists together at any level

Catenate catenate elements from a list of lists

ArrayFlatten  ▪  ArrayReshape  ▪  FlattenAt  ▪  Splice  ▪  Nothing

TakeList take a succession of sublists from a list

Sort sort lexicographically or with any comparison function

ReverseSort sort reverse lexicographically

SortBy sort by the values of a function applied to elements

AlphabeticSort  ▪  NumericalSort  ▪  LexicographicSort  ▪  ReverseSortBy

Reverse reverse a list at any level

RotateLeft, RotateRight cyclically rotate lists at any depth

Transpose transpose any collection of levels

ArrayReduce reduce dimensions of an array by applying a function

ArrayResample resample an array to higher or lower resolution

ArrayPad add padding on each side

ArrayFilter filter an array using local neighborhoods

Riffle intersperse additional elements

PadLeft, PadRight pad lists to be a particular length at any depth

Split split into runs of identical elements

Gather gather sublists of identical elements

Union, Tally enumerate, tally all distinct elements in a list

DeleteDuplicates delete duplicate elements in a list

DeleteDuplicatesBy delete elements for which values of a function are duplicated

DeleteAdjacentDuplicates delete duplicates adjacent to one another

SplitBy, GatherBy split, gather based on values of a function applied to elements

Tuples  ▪  Subsets  ▪  Subsequences  ▪  Permutations  ▪  RandomSample

Groupings generate all possible groupings of a list into sublists

Union  ▪  Intersection  ▪  Complement

Sequence-Oriented Operations

SequenceSplit split a list at sequences matching a pattern

SequenceReplace replace sequences in a list

Element-Oriented Operations »

ReplacePart  ▪  Take  ▪  Drop  ▪  Append  ▪  AppendTo