Added function to sort linked list.