Skip to content
Snippets Groups Projects
Commit 7cc4b757 authored by Chris Smith's avatar Chris Smith
Browse files

FS#1648 - sort acronyms into descending order by string length

darcs-hash:20090419160806-f07c6-a2d1bd681e2dd369422bd3839d2837833288cee5.gz
parent 3c147a01
No related branches found
No related tags found
No related merge requests found
......@@ -611,6 +611,7 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
var $pattern = '';
function Doku_Parser_Mode_acronym($acronyms) {
usort($acronyms,array($this,'_compare'));
$this->acronyms = $acronyms;
}
......@@ -633,6 +634,21 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
function getSort() {
return 240;
}
/**
* sort callback to order by string length descending
*/
function _compare($a,$b) {
$a_len = strlen($a);
$b_len = strlen($b);
if ($a_len > $b_len) {
return -1;
} else if ($a_len < $b_len) {
return 1;
}
return 0;
}
}
//-------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment