A sorting algorithm is a set of instructions that are used to arrange a collection of data elements in a particular order. The most common orderings are in numerical or alphabetical order, but data can be sorted according to any predetermined ordering criteria.