https://cs.slides.com/colt_steele/elementary-sorting-algorithms
What is sorting?
Sorting is the process of rearranging the items in a collection (e.g. an array) so that the items are in some kind of order.
Examples
- Sorting numbers from smallest to largest
- Sorting names alphabetically
- Sorting movies based on release year
- Sorting movies based on revenue
function sort(arr){
}
Why do we need to learn this
- Sorting is an incredibly common task, so it’s good to know how it works
- There are many different ways to sort things, and different techniques have their own advantages and disadvantages
- Classic interview process
JavaScript has a sort method…
- Yes , it does!
- — But it doesn’t always work the way you expect.
["Steele","Colt","Data Stuctures","Algorithms"].sort();
[ 6, 4, 15, 10].sort();
// The default sort order is according to string Unicode points