How sort list?



> This is only example. Other example:
> I ned
> [[7,1],[10,9],[5,7],[4,2],[6,8],[1,6],[9,4],[3,5],[8,10],[2,3]]
> transform to
> [[1,6],[6,8],[8,10],[10,9],[9,4],[4,2],[2,3],[3,5],[5,7],[7,1]]
>
> This lists are solutions of Hamiltonian Cycle problem or Travelling
> Salesman Problem see
> http://www.math.jmu.edu/~lucassk/Papers/determinant.pdf

_IF_ these lists are known to be cycles,
then there should be no problem to construct an O(n^2) algorithm
to find your preferred order.

Step 0. construct an empty new list
Step 1. start with the first pair in the old list.
		call it f,
		remove it from the old list and cons it to the new list.
Step 2. iterate through the old list to find a suitable pair which
		is the precessor of f.
         call it f,
		remove it from the old list and cons it to the new list.
Step 3. repeat step 2 until your old list is empty.

O.K. your first pair of the new list need not start with 1
but that's an easy homework.

for manipulating the lists in maxima, use

l : []
l : cons(f,l)
f : first(lold)
lold : rest(lold)