Cool, thanks for fixing that for me. I can't believe I missed the $ :p The reason i'm not sorting in MySQL (which, I agree is much faster and easier to use) is because not all of these values are stored in the database). Actually....now that I think about it I might be able to use MySQL sorting after all... I'll keep you all posted. On 2/19/06, Ryan McElroy <ryan@xxxxxxxxxxxxxxxxx> wrote: > > Bubblesort is fixed. You had a missing $ before the last j in the compare > on line 68. It doesn't seem to sort backwards yet. > > I also took the liberty of of changing $fields and $count to be more > dynamic, from the passed-in array and value, which seems a lot more robust > to me: > > $fields = array_keys($a); > $count = count($a[$sortField]); > > That way, if you pass in a completely different array that is still in the > same format, it will still work. > > ~Ryan > > > > Ryan McElroy wrote: > > 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 > PHP/MySQL programmer > > -- Steven Buss steven.buss@xxxxxxxxx PHP/MySQL programmer