A Simple Bubble Sort Function

geoff at callan.UUCP geoff at callan.UUCP
Sun Jun 10 04:13:53 AEST 1984


Jack Purdum is rapidly getting a reputation as an idiot with me.  I thought
that by now *EVERYBODY* knew that the bubble sort is for cretins.  If you
want a quick simple sort, write a "selection sort":  search 0 thru n for the
largest item and swap it with the item in slot n;  repeat with n=n-1 until
done.  This is exactly the effect that the bubble sort achieves (think about
it for a while if you aren't sure), but without all the unnecessary exchanges.

Moral:	Don't waste your effort optimizing the wrong solution to the problem.

	Geoff Kuenning
	Callan Data Systems
	...!ihnp4!wlbr!callan!geoff



More information about the Comp.sources.unix mailing list