Sorting
- Completed sort_compare routine to mimic 1.9.2, but using std::sort. - Added blank task to the unit tests to prove the sorting is working (it wasn't), then fixed all.
This commit is contained in:
@@ -614,21 +614,41 @@ bool sort_compare (int left, int right)
|
||||
|
||||
// nothing < something.
|
||||
if (cell_left == NULL && cell_right != NULL)
|
||||
return (sort_type == Table::ascendingNumeric ||
|
||||
sort_type == Table::ascendingCharacter ||
|
||||
sort_type == Table::ascendingPriority ||
|
||||
sort_type == Table::ascendingDate ||
|
||||
sort_type == Table::ascendingDueDate ||
|
||||
sort_type == Table::ascendingPeriod) ? true : false;
|
||||
{
|
||||
if (sort_type == Table::ascendingDueDate)
|
||||
return true;
|
||||
|
||||
else if (sort_type == Table::descendingDueDate)
|
||||
return false;
|
||||
|
||||
else if (sort_type == Table::ascendingNumeric ||
|
||||
sort_type == Table::ascendingCharacter ||
|
||||
sort_type == Table::ascendingPriority ||
|
||||
sort_type == Table::ascendingDate ||
|
||||
sort_type == Table::ascendingPeriod)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// something > nothing.
|
||||
if (cell_left != NULL && cell_right == NULL)
|
||||
return (sort_type == Table::ascendingNumeric ||
|
||||
sort_type == Table::ascendingCharacter ||
|
||||
sort_type == Table::ascendingPriority ||
|
||||
sort_type == Table::ascendingDate ||
|
||||
sort_type == Table::ascendingDueDate ||
|
||||
sort_type == Table::ascendingPeriod) ? false : true;
|
||||
{
|
||||
if (sort_type == Table::ascendingDueDate)
|
||||
return false;
|
||||
|
||||
else if (sort_type == Table::descendingDueDate)
|
||||
return true;
|
||||
|
||||
else if (sort_type == Table::ascendingNumeric ||
|
||||
sort_type == Table::ascendingCharacter ||
|
||||
sort_type == Table::ascendingPriority ||
|
||||
sort_type == Table::ascendingDate ||
|
||||
sort_type == Table::ascendingPeriod)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Differing data - do a proper comparison.
|
||||
if (cell_left && cell_right)
|
||||
@@ -693,11 +713,11 @@ bool sort_compare (int left, int right)
|
||||
{
|
||||
// something > nothing.
|
||||
if ((std::string)*cell_left != "" && (std::string)*cell_right == "")
|
||||
return false;
|
||||
return true;
|
||||
|
||||
// nothing < something.
|
||||
else if ((std::string)*cell_left == "" && (std::string)*cell_right != "")
|
||||
return true;
|
||||
return false;
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user