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; 
});
有帮助吗?

解决方案

Just reverse the arguments to strcmp.

usort( $bla, function( $a, $b )
{
    return strcmp( $b->title, $a->title ); 
}); 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top