Linked by MOS6510 on Thu 10th Jan 2013 23:25 UTC
Thread beginning with comment 548453
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.
Using function pointers to pass a compare function to a sort function is more complicated than blah.sort(). Particularly if your collection has a natural sort order, like strings.
The point of passing a compare function to a sort function is for when you want to sort things into a different order than the natural one.
The point of passing a compare function to a sort function is for when you want to sort things into a different order than the natural one.
Except in C, there is no way to sort anything without passing a compare function to qsort. Even an array of ints needs a hand-coded, if trivial, compare function passed to it.





Member since:
2006-05-20
Fair enough. I stand by the basic premise, however. Using function pointers to pass a compare function to a sort function is more complicated than blah.sort(). Particularly if your collection has a natural sort order, like strings.
Ha! Okay, it was 4 in the morning when I wrote that, but the fact that I screwed up my example kinda proves the point.