1
usort( $bla, function( $a, $b )
{
    return strcmp( $a->title, $b->title ); 
}); 

is returning my list in DESC order rather than ASC order... How would I go about tweaking this?

I tried:

usort( $bla, function( $a, $b )
{
    return ( strcmp( $a->title, $b->title ) < 0 ) ? $a->title : $b->title; 
});
4

1 回答 1

3

Just reverse the arguments to strcmp.

usort( $bla, function( $a, $b )
{
    return strcmp( $b->title, $a->title ); 
}); 
于 2013-07-26T17:10:30.700 回答