BNY interview question

sort an linked list and find middle node