diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2011-05-16 09:03:58 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2011-05-16 09:03:58 +0400 |
commit | 30b0919c5c152661f8aef1ff3a299720ec57842c (patch) | |
tree | 008881a6fd5d2f14d24fd17f2fbe0b2e8d9d55e3 /core/DataTable/Filter/Sort.php | |
parent | d37c0b2edc872ea7d4a39bd836b2d4cf7b8f7316 (diff) |
More mysqli fun.. now sorting items with the same "sorted column" value by "label" to ensure consistent ordering if the sql driver decides to return rows in random order...
git-svn-id: http://dev.piwik.org/svn/trunk@4700 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/DataTable/Filter/Sort.php')
-rw-r--r-- | core/DataTable/Filter/Sort.php | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/core/DataTable/Filter/Sort.php b/core/DataTable/Filter/Sort.php index 213ca1ea41..1fadf73e4d 100644 --- a/core/DataTable/Filter/Sort.php +++ b/core/DataTable/Filter/Sort.php @@ -57,21 +57,18 @@ class Piwik_DataTable_Filter_Sort extends Piwik_DataTable_Filter : ( !isset($a->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort]) ? 1 - :( - !isset($b->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort]) - ? -1 - : $this->sign * ( - $a->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort] - < $b->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort] - ? -1 - :( isset($a->c[Piwik_DataTable_Row::COLUMNS]['label']) - ? strnatcasecmp( - $a->c[Piwik_DataTable_Row::COLUMNS]['label'], - $b->c[Piwik_DataTable_Row::COLUMNS]['label'] - ) + :( ($a->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort] != $b->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort] + || !isset($a->c[Piwik_DataTable_Row::COLUMNS]['label'])) + ? ( $this->sign * ( + $a->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort] + < $b->c[Piwik_DataTable_Row::COLUMNS][$this->columnToSort] + ? -1 : 1 - ) + ) ) + : -1 * $this->sign * strnatcasecmp( + $a->c[Piwik_DataTable_Row::COLUMNS]['label'], + $b->c[Piwik_DataTable_Row::COLUMNS]['label']) ) ) ; |