Testing sorting algorithms

Some time ago I had to deal with sorting algorithms. Besides my main task I found a good way how to test custom sorting algorithms. This blog entry is one of early birds, more about sorting algorihtms is coming soon. Hopefully some time after TechEd 2007 for Developers. The procedure I wrote to test sorting algorithms is simple and works. Of course, I am always opened for better ideas if somebody wants to suggest some. Here's the little overview about what I've done.


NB! This blog is moved to gunnarpeipman.com

Click here to go to article


  • What will happen if the array contains duplicates ? Your IsSorted() method will return false and for me the array {1,2,2,2,3} is sorted.
    I think you need to change the comparision from
    (array[i - 1].CompareTo(array[i]) > 0) to
    (array[i - 1].CompareTo(array[i]) >= 0).

  • Thanks Petar, it was my bug. Now it is fixed :)

Comments have been disabled for this content.