Stable sort
A sort that keeps the relative order of equal elements. It lets you sort by several criteria in a row.
Example
Students sorted by name: (A, 19), (D, 19). Sorting by age with a stable one, A stays before D.
Test yourself: Stable sort
What makes a good sort
A stable sort keeps the relative order of ___ elements.
If 2 orders of 500 dollars were 1st and 2nd, after sorting by price they're still 1st and 2nd between themselves.
Selection sort
Selection sort is a stable sort.
In [5a, 5b, 1], swapping 5a with 1 gives [1, 5b, 5a]: 5a ended up after 5b.
Bubble sort
Bubble sort is a stable sort.
It only swaps if the left one is larger, never if they're equal: in [5a, 5b, 1], the 2 fives end up in the same order.
0/3
â–¶ PlayLessons that use it
What makes a good sort
5 things you ask of it
Selection sort
Picking the smallest, over and over
Bubble sort
The largest rises like a bubble
Insertion sort
Like arranging the cards in your hand
Quick sort
A pivot and 2 sides
Merge sort
Split in half and merge in order
Heap sort
Take the maximum and leave it at the end
Bucket sort
Split into buckets and sort each one
Counting sort
Sorting by counting
Radix sort
Digit by digit
GraphQL and gRPC
Other ways to talk to an API
