Someone emailed me today to ask me how they could sort results, returned from my PhpDelicious class, alphabetically by description. It seems to me that the solution would probably be useful to other people hence the post.
<?phprequire('php-delicious.inc.php');function SortByDesc($sA, $sB) {return strcmp($sA['desc'], $sB['desc']);}$oDelicious = new PhpDelicious(YOUR_USERNAME, YOUR_PASSWORD);if ($aPosts = $oDelicious->GetAllPosts()) {usort($aPosts, 'SortByDesc');echo "<ul>";foreach ($aPosts as $aPost) {echo "<li><a href=\"{$aPost['url']}\">{$aPost['desc']}</a></li>";}echo "</ul>";}?>
It uses the usort function which sorts array values using a user-defined comparison function - in this case SortByDesc. This custom function uses strcmp, which does a case sensitive string comparison, to determine which parameter should appear first. If you want to do a case insensitive comparison instead replace strcmp function with strcasecmp.
strncmp and strncasecmp which compare the first n characters of each word, case-sensitively and case-insensitively respectively, are also worth a look.