Compares two adjacent elements and swaps if the first element is greater than the other one .
while ( curr . next != null ) { temp = curr . next ; while ( temp != null ) { if ( temp . data < curr . data ) { var t = temp . data ; temp . data = curr . data ; curr . data = t ; } temp = temp . next ; } curr = curr . next ; } }