Buble sorter

The buble sorter algorithm is a well known and very simple way of sorting numbers.It is best suited to small sets of numbers,since for larger sets numbers.For sorting ints, a method to do a buble sor might look like this





Class BubbleSorter
{
static public void sort(object [ ] sortarray ,compareOp gtmethod)
{
for (int i=0;i {
for(int j=i+1;j {
if (gtMethod(sortArray [ j ] , sortarray[i]))
{
object temp = sortarray [ i ];
sortarray [ i ] = sortarray [ j ];
sortarray [ j ] = temp;
}
}
}
}
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: