title: bubble sort linked list, swapping pointers. C
body: <p>I'm trying to swap two pointers of a singly linked list using the bubble sort.
  I've made the compare function, and its working good.
  In the swap function, the swap is working good, I've managed to swap between the node and the <code>node-&gt;next</code>, though the linked list "lose" the info of the node (after the swap), so the first node in the linked list is <code>node-&gt;next</code>.
  I'm using a generic function which do the bubble sort and call the compare function and the swap function.</p>
  
  <p>Any idea why this happens?</p>
  
  <pre><code>void swap_arr(void **arr,int i , int j)
  {
  
    Team *teamList = (Team*) arr ;    
    Team *teamI = (Team*) arr , *teamJ ;
    Team *temp ;
    Team *temp1;
    int z;
  
  
    // Receives instead i
    for(z=0; z&lt;i; z++)
      teamI = teamI-&gt;next;
  
    //teamJ is the i+1    
    teamJ =  teamI-&gt;next;
  
    temp = teamI;
    temp1 = teamJ-&gt;next;
  
  
    teamI = teamJ ;
  
    teamJ = temp;
  
    if (temp1-&gt;next-&gt;next==NULL)
       teamJ-&gt;next = NULL;
    else
       teamJ-&gt;next = temp1-&gt;next;
  
    teamI-&gt;next = teamJ;
  
     if (temp1==NULL)
       teamJ-&gt;next=NULL;
    else
       teamJ-&gt;next = temp1;  
  }
  </code></pre>