queue: Fix up sorting

If years are equal then sort by album name.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-01-06 08:24:33 -05:00
parent 6cfd0d5c51
commit 27c7dc91d8
2 changed files with 8 additions and 7 deletions

View File

@ -70,8 +70,6 @@ static inline int track_compare(Track *lhs, Track *rhs, sort_t field)
switch (field) {
case SORT_ARTIST:
return lhs->artist()->compare(rhs->artist());
case SORT_ALBUM:
return lhs->album()->compare(rhs->album());
case SORT_COUNT:
return lhs->count() - rhs->count();
case SORT_GENRE:
@ -85,7 +83,10 @@ static inline int track_compare(Track *lhs, Track *rhs, sort_t field)
case SORT_TRACK:
return lhs->track() - rhs->track();
case SORT_YEAR:
return lhs->album()->year() - rhs->album()->year();
if (lhs->album()->year() - rhs->album()->year() != 0)
return lhs->album()->year() - rhs->album()->year();
case SORT_ALBUM:
return lhs->album()->compare(rhs->album());
}
return 0;
}

View File

@ -304,7 +304,7 @@ void test_select()
unsigned int exp_sort_title[] = { 1, 18, 19, 16, 20, 8, 2, 9, 23, 10, 17, 11,
3, 21, 4, 0, 5, 22, 6, 12, 7, 13, 14, 15 };
unsigned int exp_sort_ye_ti[] = { 0, 3, 2, 1, 7, 6, 5, 4, 11, 10, 9, 8,
22, 21, 17, 23, 20, 16, 19, 18, 15, 14, 13, 12 };
17, 16, 19, 18, 22, 21, 23, 20, 15, 14, 13, 12 };
unsigned int _test_sort_title(unsigned int i)
{
@ -329,9 +329,9 @@ unsigned int _test_sort_index(unsigned int i)
unsigned int _test_sort_ye_ti(unsigned int i)
{
if ((*Q)[i]->index() == exp_sort_ye_ti[i])
return LOOP_PASSED;
return LOOP_FAILED;
if ((*Q)[i]->index() != exp_sort_ye_ti[i])
return LOOP_FAILED;
return LOOP_PASSED;
}
void test_sorting()