Quote:
Originally Posted by sparklywater
If the 'default_sort_order' is set to 'Title (ascending)' for a given category, and the entries in that category are an ascending list of numbers (1, 2, 3, 4, 5 ... 100 ), then LDM does not correctly list these entries in ascending order of numbers. Instead, it lists the numbers like this:
1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3, 30, 31, 32, 33 ...
|
This is a well-known problem with computer sorts - they don't do what people consider right! It seems that one can fix the problem without any unwanted side effects by making a small change to the database query.
edit includes/local_links_include.php
find function ldm_get_sortsql and change the function's code as follows:
PHP Code:
function ldm_get_sortsql($sort, $withlinkdorder=1) {
$linkdorder = ($withlinkdorder ? "linkdorder ASC, " : "");
if (is_numeric($sort)) {
$sorder = $linkdorder." linkrecenthits DESC, linkname + 0 ASC, linkcatid ASC";
}
else {
switch ($sort) {
case 'r': $sorder = $linkdorder." IF(numrate>0,(totrate/numrate),numrate) DESC, linkname + 0 ASC, linkcatid ASC"; break;
case 'R': $sorder = $linkdorder." IF(numrate>0,(totrate/numrate),numrate) ASC, linkname + 0 ASC, linkcatid ASC"; break;
case 'd': $sorder = $linkdorder." linkdate DESC, linkname + 0 ASC, linkcatid ASC"; break;
case 'D': $sorder = $linkdorder." linkdate ASC, linkname + 0 ASC, linkcatid ASC"; break;
case 'h': $sorder = $linkdorder." linkhits DESC, linkname + 0 ASC, linkcatid ASC"; break;
case 'H': $sorder = $linkdorder." linkhits ASC, linkname + 0 ASC, linkcatid ASC"; break;
case 'u': $sorder = $linkdorder." linkusername + 0 DESC, linkname + 0 ASC, linkcatid ASC"; break;
case 'U': $sorder = $linkdorder." linkusername + 0 ASC, linkname + 0 ASC, linkcatid ASC"; break;
case 'n': $sorder = $linkdorder." linkname + 0 DESC, linkcatid ASC"; break;
case 'N':
default: $sorder = $linkdorder." linkname + 0 ASC, linkcatid ASC"; break;
}
}
($hook = vBulletinHook::fetch_hook('ldm_sortsql_complete')) ? eval($hook) : false;
return $sorder;
}
(the change is to add "+ 0" after every text field)
|