Well ordering is a concept that is trivial when finite sets are involved. Invoking the term "well ordering" instead of just sorting implies needing theory and concepts that are rarely needed. You obviously don't need that theory, as you seem to want to implement sorting of a finite set. Every finite set has many relations that make it well-ordered, the most obvious one is the injection of the set into the set of natural numbers ("counting").
If cleaning up your code is too much work for you, why do you expect us to wade through it or make guesses about where in your code you go wrong?
|