Compare
Most sorting algorithms repeatedly ask a simple question: which of these two values should come first?
Watch arrays sort themselves step by step: compare, swap, partition, merge, and finish.
Most sorting algorithms repeatedly ask a simple question: which of these two values should come first?
After comparing, the algorithm swaps, shifts, partitions, or writes values into better positions.
Eventually every value is in order. Some algorithms prove sorted regions as they go; others rebuild the whole array.
Some algorithms split a big problem into smaller problems, solve those, then combine the answers. Merge Sort and Quick Sort both use this idea.
Fast algorithms often use more memory, recursion, or coordination. A simple algorithm may be easier to understand but slower on big arrays.
Imagine bubbles rising in water. Bigger values keep swapping to the right until they “float” to the end.
Selection Sort keeps finding the smallest remaining value and placing it into the next open spot.
Quick Sort picks a pivot, moves smaller values to one side and larger values to the other, then repeats on each side.
This means “split, solve, combine.” Instead of sorting one huge list directly, split it into smaller lists, sort those, then combine the results.