[stamp] Re: sorting algorithms
- From: Ryan McElroy <ryan@xxxxxxxxxxxxxxxxx>
- To: stamp@xxxxxxxxxxxxx
- Date: Sun, 19 Feb 2006 13:45:17 -0800
Steven,
I am very curious as to why you are implementing a bubble sort in PHP
for this... First off, PHP is slow. Secondly, bubble sort is slow. Not
that we're lacking for cycles here (I don't think 30-50 teams bubble
sorted in PHP is going to blow up the web server or anything), I just
think I would do it differently.
The way I would do it (did do it last year) is to let MySQL, which has
optimized sorts written in C, do the sorting for me. At the very worst,
this means creating temporary tables. At the very best, this allows you
to exercise some SQL prowess to get the exact information you want with
one select statement.
On the other hand, I'm the one sitting here writing an email and you're
the one doing all the real work. So I'm going to take a look at your
sort routine and try to fix it or perhaps replace it with a merge sort.
If this email piques your curiosity and you want to take a look at
having MySQL do the dirty work, let me know and I'll show you how I
accomplished that last year.
~Ryan
Steven Buss wrote:
Arrrgh, apparently something isn't working quite right with my bubble
sort, the rankings page might be a bit behind schedule unless I get it
working tomorrow. If you want to try to fix it, its rankings.php
(function bubblesort())
--
Steven Buss
steven.buss@xxxxxxxxx <mailto:steven.buss@xxxxxxxxx>
PHP/MySQL programmer
Other related posts: