Sorting Algorithms

I must say that this is a very simple post for the beginners. My knowledge about sorting is far more scary, and I do not intend to put it into this blog right now ;-)

A good discussion about this topic is worth much more than even a full article, but I think I can just put here the very essence of the story, I repeat, for newbies. Ever since computers and ever since math, the concept of sorting was introduced and defined. OK. As far as a small programmer should be concerned, there are two types of sorting involved:

1. Sorting by one field
2. Sorting by n fields

For the first one there are so many methods, one faster than the other and alltogether slower than what would be ideal. It’s the second method that raised issues: How can one sort a list of objects, when all these objects must be sorted by several criteria (sg. criterion) and they provide fields for each?

A simple approach would seem to be to sort them for each criterion, that is to sort them several times. But no, you can’t because you would scramble the previous sorting this way. You must assign costs to the elements based on the criterion’s importance and combine the costs for each criterion in a n-dimensional valid cost that would hierarchize the list according to the desired way. Then sort with method 1, by a field, where the field is the cost. Simple, he?

If you are interested about sorting in Java, a good article I found here:
http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

A nice visual comparsion of various sorting methods would be this:
http://cg.scs.carleton.ca/~morin/misc/sortalg/

Please note, I am not sure for how long these links are going to work… If they become dead, please let me know by commenting… Hopefuly they should work for at least a few years (or should I hope months).


Comments »

The URI to TrackBack this entry is: http://premis.blogsome.com/2006/06/13/sorting-algorithms/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.