- add TypeScript support
Sorting algorithms ๐
Nearly every standard library offers data structures that can be sorted without really thinking about it. Still, it might come in handy to know about commonly used sorting algorithms or even implement some of them yourself as an exercise. After all, most sorting algorithms make heavy use of array indexing and recursion, and for this reason alone, they are often used as a medium to learn about and apply these concepts.
Even though sorting algorithms can be categorized by just a handful of different methods, there are hundreds of variations out there. Some algorithms are more efficient than others. You can compare their efficiency by both time complexity and memory consumption. It is worth noting that some sorting algorithms may perform worse in certain situations while, on average, they perform better than others. Finally, a stable sorting algorithm is expected to preserve the order of elements considered to be equal.
As you can tell, choosing the right sorting algorithm may not always be so easy. For this reason, I have compiled the following list, including implementation details for future reference:
Name | Best Average Worst | Memory | Stable | Method | Visualization |
---|---|---|---|---|---|
Quicksort | | No | Partitioning | ||
Merge sort | | Yes | Merging | ||
Heapsort | | 1 | No | Selection | |
Insertion sort | | 1 | Yes | Insertion | |
Selection sort | | 1 | No | Selection | |
Shellsort | | 1 | No | Insertion | |
Bubble sort | | 1 | Yes | Exchanging |
Further readingโ
- Sorting algorithm on Wikipedia, the free encyclopedia
Spring event 2023 ๐ท
The snow begins to melt and flowering plants are about to bloom.
This is your time to get creative! ๐
Implement a spring-themed sketch, join Discord and share your result in #general within March 21st and June 21st. At the end of the event all submissions will be collected in a separate blog post on this website and we will do a vote. The submission with the highest number of votes wins ๐.
Have fun and good luck! ๐
p8g v0.8.3 is out! ๐
p8g v0.8.2 is out! ๐
- fix keyCode and mouseButton to also be set on release
p8g v0.8.1 is out! ๐
- allow memory growth
p8g v0.8.0 is out! ๐
- fix C/C++ runtime errors on Windows
- fix font smoothing
p8g v0.7.2 is out! ๐
- fix font rendering artifacts
p8g v0.7.1 is out! ๐
- fix bug in JavaScript binding that prevented drawing buffer from being preserved
- add more JavaScript examples
p8g v0.7.0 is out! ๐
- add JavaScript support
- make docs more mobile-friendly