Hi Alex, > A typical example would be sorting a list of customers by city, name and > customer number, in that order. A binary comparison for 'sort2' would > look like > > (sort2 > (collect ... '+CuSu ...) > '((CuSu1 CuSu2) > (cond > ((<> (; CuSu1 ort) (; CuSu2 ort)) > (> (; CuSu2 ort) (; CuSu1 ort)) ) > ((<> (; CuSu1 nm) (; CuSu2 nm)) > (> (; CuSu2 nm) (; CuSu1 nm)) ) > (T > (> (; CuSu2 nr) (; CuSu1 nr)) ) ) ) ) > > This binary function is rather complicated (and thus slow), and it might > be called nearly O(N^2) times.
it will be called as many times as the C function 'compare' is called. Not sure about the picolisp 'sort' function, but usual sorting algorithms are O(N*log(N)) so it will be called O(N^2) times only if the built-in 'sort' is O(N^2). I guess the built-in 'sort' function is O(N*log(N)) so the code above will be O(N*log(N)) too. Cheers, Tomas -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe