单链表的冒泡排序和数组的冒泡排序是很像的。
public void sort(){ Node cur = head; Node tmp = null; while(cur != tmp){ while(cur.next != tmp){ if(cur.data > cur.next.data){ int temp = cur.data; cur.data = cur.next.data; cur.next.data = temp; } cur = cur.next; } tmp = cur; cur = head; } }