teeworlds/teeworlds — pull request #1169 by SushiTee (2013-12-09 13:35:31+00:00)
Title: sorting algorithms

I tried to implement some sorting algorithms for the sorted_array template as the bubble sort is very very slow (I speeded up that a bit too)

I tested the code with a random list in different sizes with all algorithms. In this cases quick sort was always the fastest as expected. After this I changed only 10 values in the already sorted list and run the algorithms again. In this case quicksort was very slow. All in all shell sort always insures acceptable sorting times in both cases (At least in my tests) which is why I set shell sort the default sort algorithm for the sorted_array template.
Maybe there is still a lot you can optimize but the times are already much much faster than before :)
I also added merge sort in case a stable sort is needed which is much faster than bubble sort.