Here are my suggestions on column sorting. There are two things that could be added that would make it better.
1) You want to emulate the behavior of Windows Explorer. Don't remember the sort order for each column individually. Instead, remember only the last sorted column and the direction it was sorted. Then, when user clicks a column, the decision is simple: if this column is the same as the previously sorted column, reverse the sort direction. Otherwise do an ascending sort. I find myself always getting descending sorts when I almost never want them -- because a while ago I had sorted on that column and then done other things, and dAP is remembering that previous sort!
It's hard to explain, here is pseudo-code that might make the idea clearer:
// pseudo-code
void sort_by_column(int col)
{
static int prev_col = -1;
static bool prev_ascending = true;
bool ascending = col == prev_col ? !prev_ascending : true;
sort_it(col, ascending); // do actual sort here
prev_col = col;
prev_ascending = ascending;
}
This will prevent 99% of the unwanted descending sorts.
2) It is impossible to get an album sorted by track number, unless you use a stable sort routine. It's a bummer! So, in the above, the sort_it() routine should do a stable sort. There is a stable sort right there in STL that you can use, named, oddly enough, std::stable_sort() :-)
Just suggestions, to make dAP and MMC the best!
1) You want to emulate the behavior of Windows Explorer. Don't remember the sort order for each column individually. Instead, remember only the last sorted column and the direction it was sorted. Then, when user clicks a column, the decision is simple: if this column is the same as the previously sorted column, reverse the sort direction. Otherwise do an ascending sort. I find myself always getting descending sorts when I almost never want them -- because a while ago I had sorted on that column and then done other things, and dAP is remembering that previous sort!
It's hard to explain, here is pseudo-code that might make the idea clearer:
// pseudo-code
void sort_by_column(int col)
{
static int prev_col = -1;
static bool prev_ascending = true;
bool ascending = col == prev_col ? !prev_ascending : true;
sort_it(col, ascending); // do actual sort here
prev_col = col;
prev_ascending = ascending;
}
This will prevent 99% of the unwanted descending sorts.
2) It is impossible to get an album sorted by track number, unless you use a stable sort routine. It's a bummer! So, in the above, the sort_it() routine should do a stable sort. There is a stable sort right there in STL that you can use, named, oddly enough, std::stable_sort() :-)
Just suggestions, to make dAP and MMC the best!
Comment