Hey,
I'm trying to sort a doubly linked list using the "bubbles source" sort.
It's not working good
Someone can help me? What's I'm doing wrong?
boolean sorted = false; car carA = list.getHead(); car carB = list.getHead().getNext(); while (!sorted) { sorted = true; while (carA != getLastcar(list).getPrev()) { sorted = false; if (carA.greaterThan(carB, sumEnum)) { swap(list, carA, carB); } car tempcarB = carB; carB = carA.getNext(); carA = tempcarB.getNext(); } public static void swap(carList list, car carA, car carB) { car carBPointed2 = carB.getNext(); car carAPreved2 = carA.getPrev(); carB.setNext(carA); carA.setNext(carBPointed2); carB.setPrev(carAPreved2); carA.setPrev(carB); carA.getNext().setPrev(carA); if (carB.getPrev() == null) { list.setHead(carB); } }