adding sorted linked list function