| Article Index |
|---|
| Sort list |
| Souce code |
| Documentation |
| Test cases & Compatibility |
| All Pages |
Introduction :
The aim of this program is to sort the elements of the list. This is done by considering each element and placing it before an element greater to it. Consider the following list of 3 nodes.

Now, 2 > 3, so it remains as such. Now, 3 < 1, so 3 and 1 are swapped using 2 temporary pointers temp1 and temp2. Another pointer temp is used to traverse through the list till NULL is reached. A pointer 'halt' is made to point the NULL. So, now the list becomes


Now the halt is made to point 3 as it is already sorted. Now 2 and 1 are compared. As 2 > 1, they are swapped. So, now the halt is made to point 2 and finally 1. So, the sorted list is
| < Prev | Next > |
|---|




