PDA

View Full Version : Column sorting in dAP



dsieber
05-05-2002, 12:21 PM
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() :-)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrfAlgorithmStablesort.asp

Just suggestions, to make dAP and MMC the best!

Spoon
05-05-2002, 01:12 PM
Thanks, I didn't know explorer did this.

dsieber
05-06-2002, 11:03 AM
Thanks for reading my suggestions, Spoon. I know I'm posting a lot of them, but somebody has to give you a hard time, and I was volunteered :-)

Actually, I've tried a lot of players but I am settling on dAP as my player of choice because it has many features that I really like, and it is obvious that you are working very hard to make all of dBpowerAMP great. If I didn't like it a *lot*, I wouldn't be speaking up and making suggestions like I am. Keep up the great work!