Step One: Watch Sorting Algorithms in JavaScript
Step Two: Fork this gist.
Step Three: Respond to this question in your fork: "What are some of the balances and trade offs between different sorting algoritms?"
- The .sort() is lexographical, so 10 comes before 7.
- Three important characteristics:
- stability- maintain relative order
- runtime anaylsis
- algorithm implementationStable sorts maintain
- Bubble sort- have to check through every item- two for loops and an if statement. Easy to implement
- Merge sort- fast and stable but needs resources for temp space
- Insertion- doesn't need that many resources, but slow when data is reverse ordered.
Step Four: Totally Optional: take a look at some of the other forks and comment if the spirit moves you.