Selection sort

easy

Always exactly n−1 swaps, whatever the input - which makes it the right choice when writes are far more expensive than reads. The comparison count never changes either, so there is no best case to exploit.

Best O(n²)Average O(n²)Worst O(n²)Space O(1)Not stableIn place
Loading the selection sort engine…

Where to go next