# Sort

- Uses
- Necessary for some algorithms
- Speeds processing for others (e.g. sorted index)
- Consider other data structures (hash, tree)

- Radix sort
- Sort into bins
- O(n), if sort within bin doesn't matter
- O(n log n) if you do log n radix sorts

- Insertion/Bubble sort
- Bad to sort from unordered
- Not bad for nearly ordered
- Good for minor changes

- O(n log n) sort
- quick sort
- OK, O(n
^{2}) if already sorted, O(n log n) average case/randomized

- merge sort (heap sort, etc)

- Parallel sort (bitonic)
- Build from max/min steps & swaps
- Avoid conditionals
- O(log
^{2} n) time for n processors
- Algorithm
- bitonic sequence = /\
- cut two bitonic sequences together to build a bigger one (figs from Wikipedia)
- reorder to unify directions