Function: listsort
Section: programming/specific
C-Name: listsort
Prototype: vWD0,L,
Help: listsort(~L,{flag=0}): sort the list L in place. If flag is nonzero,
 suppress all but one occurrence of each element in list.
Doc: sorts the \typ{LIST} \var{list} in place, with respect to the (somewhat
 arbitrary) universal comparison function \tet{cmp}. In particular, the
 ordering is the same as for sets and \tet{setsearch} can be used on a sorted
 list. No value is returned. If $\fl$ is nonzero, suppresses all repeated
 coefficients.
 \bprog
 ? L = List([1,2,4,1,3,-1]); listsort(~L); L
 %1 = List([-1, 1, 1, 2, 3, 4])
 ? setsearch(L, 4)
 %2 = 6
 ? setsearch(L, -2)
 %3 = 0
 ? listsort(~L, 1); L \\ remove duplicates
 %4 = List([-1, 1, 2, 3, 4])
 @eprog\noindent Note the \kbd{\til L}: this means that the function is
 called with a \emph{reference} to \kbd{L} and changes \kbd{L} in place:
 this is faster than the \kbd{vecsort} command since the list
 is sorted in place and we avoid unnecessary copies.
 \bprog
 ? v = vector(100,i,random); L = List(v);
 ? for(i=1,10^4, vecsort(v))
 time = 162 ms.
 ? for(i=1,10^4, vecsort(L))
 time = 162 ms.
 ? for(i=1,10^4, listsort(~L))
 time = 63 ms.
 @eprog
