[wp-hackers] wp_list_authors and DB queries

Bob wp-hackers at nj-arp.org
Thu Nov 22 03:29:07 GMT 2007


> Couldnt you just add
> ORDER BY display_name
> to the SQL Query?

No.  I tried.  It seems the GROUP BY is doing a sort, so you can't tell it 
to sort via ORDER BY.

It did give me a pretty SQL error message in my sidebar, however.  ;-)



----- Original Message ----- 
From: "DD32" <wordpress at dd32.id.au>
To: <wp-hackers at lists.automattic.com>
Sent: Wednesday, November 21, 2007 10:22 PM
Subject: Re: [wp-hackers] wp_list_authors and DB queries


> Couldnt you just add
> ORDER BY display_name
> to the SQL Query?
>
> On Thu, 22 Nov 2007 14:19:59 +1100, Bob <wp-hackers at nj-arp.org> wrote:
>
>> OK, I threw in a sort of the array.  Here's the user-defined function to 
>> do
>> the comparison:
>>
>> function wp_widget_authors_cmp($a, $b) {
>>         $al = strtolower($a->display_name);
>>         $bl = strtolower($b->display_name);
>>         if ($al == $bl) {
>>                 return 0;
>>         }
>>         return ($al < $bl) ? -1 : 1;
>> }
>>
>>
>> And the call to usort just before the foreach ($authors as $author):
>>
>> usort($authors, "wp_widget_authors_cmp");
>>



More information about the wp-hackers mailing list