sorting - selection sort on singly linked list -


The work of my algorithm ... almost ... for the reason the last two elements are in the wrong order after sorting. Also, the print statement is not showing me that first runs on the right.

  public static SLL sort (SLL list) {SLLNode first = list.first; SLLNode second; While (first! = Null) {System.out.println (first.data); // if the first goes to the other side right then = first.succ; While (second! = Null) {if (second.data.compareTo (first.data) <0) {string temp = first.data; First.data = second.data; Second.data = temp; } Second = seconds succ; } First = first. Succ; } Return list; Before sorting:   

Before sorting: FFF FAF Hi AAA by CAO

After sorting: AAA by CIO FFF Hi FF

output my print statement first <0> FFF then only FF s

Because the value of capitals is lower than lowercase letters.

ascii

Comments