I have a list made out of lists (preorder-mst) like this:
((arc graph-id vertex-a vertex-b weight) (arc graph-id vertex-a vertex-b weight) ...)
What I wanted to do was to sort the sublists by weight and, if 2 weights were equal, by vertex-b.
I tried to call a function to sort the elements
(sort preorder-mst 'compare-string-number)
(defun compare-string-number (firstLIST secondLIST)
(if (eql (fifth firstLIST) (fifth secondLIST))
(if (string-lessp (fourth firstLIST) (fourth secondLIST))
(fourth firstLIST)
(fourth secondLIST))
(when T
(if (< (fifth firstLIST) (fifth secondLIST))
(fifth firstLIST)
(fifth secondLIST)))))
It returns the correct value but doesn't sort them correctly. Any idea what is wrong with it?
My (undesired) output:
((ARC GRAFO_TEST_1 C I 2) (ARC GRAFO_TEST_1 G H 1) (ARC GRAFO_TEST_1 NIL A 0) (ARC GRAFO_TEST_1 B C 8) (ARC GRAFO_TEST_1 A B 4))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…