Sorting

Various sorting algorithms are illustrated. Here they sort either numbers or cards in an array, and cards can be sorted first by suit or number. The concepts can work with other data where you can compare one item with another.

The unsorted data is shown at the top, with the sorted data below.

Select an algorithm, it is displayed and run - you can see the moves, animating them if you want.

When swapping data a temporary variable is used - which appears as appropriate.

Numbers Cards by Suit Card by Num

Animate