N
Nobody
Heres the deal... I have an application where I have a list (as in a Windows
list control, but thats not important) displayed to the user. I sort this
list based on the list controls sort function (again, its not important that
its Windows) which ends up calling a compare function in my code:
int CompareFunc(char* str1, char* str2)
{
}
this function returns -1, 0 or 1 which gets passed on to the internal quick
sort algorithm. No problem, it all works fine.
Now I have a user in which this list displays "multi-part" items. You can
guess where this is headed , the list ends up like this:
Item (1/100)
Item (11/100)
Item (2/100)
Now while that is a "correct" string sort, its kind of lame. I could force
the user to zero-pad or zero-pad myself, but both seem kind of hokey as I am
either putting requirements on the user or changing his item text. I'd much
rather end up with:
Item (1/100)
Item (2/100)
..
..
..
Item (11/100)
As it should. Now keep in mind that this could end up in dozens of formats,
brackets, parents, dashes, asterisks, etc or any endless supply of cutesy
characters a user might enter. Even the forward slash may not be the part
separator and there may be stuff after the part #s.
I've seen some applications do this in the past, but never saw the source
for them. How can this be sorted properly without requiring the user to
enter it in a very specific format? I could never handle every possible
format in my code. There must be some kind of cool generic way to do this.
list control, but thats not important) displayed to the user. I sort this
list based on the list controls sort function (again, its not important that
its Windows) which ends up calling a compare function in my code:
int CompareFunc(char* str1, char* str2)
{
}
this function returns -1, 0 or 1 which gets passed on to the internal quick
sort algorithm. No problem, it all works fine.
Now I have a user in which this list displays "multi-part" items. You can
guess where this is headed , the list ends up like this:
Item (1/100)
Item (11/100)
Item (2/100)
Now while that is a "correct" string sort, its kind of lame. I could force
the user to zero-pad or zero-pad myself, but both seem kind of hokey as I am
either putting requirements on the user or changing his item text. I'd much
rather end up with:
Item (1/100)
Item (2/100)
..
..
..
Item (11/100)
As it should. Now keep in mind that this could end up in dozens of formats,
brackets, parents, dashes, asterisks, etc or any endless supply of cutesy
characters a user might enter. Even the forward slash may not be the part
separator and there may be stuff after the part #s.
I've seen some applications do this in the past, but never saw the source
for them. How can this be sorted properly without requiring the user to
enter it in a very specific format? I could never handle every possible
format in my code. There must be some kind of cool generic way to do this.