G+_Nevrin O Posted May 2, 2014 Share Posted May 2, 2014 Hey Coders! After watching episode 15 it reminded me of a program I wrote years ago and so I decided to adapt it to work in python. It is a program that takes several sorting algorithms and time them to see what sorts faster. It was intended to work with arrays not pythons lists but I didn't want to over complicate beginners by using pythons array system when lists work so well. So none of the ones I wrote take advantage of some of the things that make lists so useful. They all treat the lists as if they are arrays so that means they will probably not be as efficient as they could be if properly designed for python. So think of it more as a concept of different sorting methods as apposed to the proper way to sort in python That being said they are still quite accurate. Thanks all, please comment below. https://github.com/NevrinO/Coding/blob/master/Python/Sorting.py Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted May 2, 2014 Share Posted May 2, 2014 Great showcase of popular sorting algorithms. I had to write many of those myself in the college days. I'll have to take a closer look at the Heap sort. I've never understood how it works. I think the only one I've used professionally is the Quicksort back in the TurboPascal days. Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted May 3, 2014 Share Posted May 3, 2014 Python's built-in sort is a kind of hybrid merge/insertion sort created by Tim Peters. It's optimized for partially sorted data, which is a very common case in real-world data. Link to comment Share on other sites More sharing options...
G+_Nevrin O Posted May 3, 2014 Author Share Posted May 3, 2014 thanks Lee, was gonna ask that to see if anyone knew. i tried searching for it but it seems like few care about how these things work. Link to comment Share on other sites More sharing options...
G+_Wesley Kerfoot Posted May 3, 2014 Share Posted May 3, 2014 It's called TimSort, I guess he isn't very modest but I don't mind :p Link to comment Share on other sites More sharing options...
Recommended Posts