 <p>IMHO, the concept is wrong. You dont need to use merge-sort here. Try searching for PriorityQueue or actually BinaryHeap in order to solve this task. Secondly, merge sort on linked list is not a good idea since it will not be efficient at all. I think you should totally rework your solution.</p> <p>NB. Just implement the operation YourLinkedList.getByIndex() for convinience, add the size atribute to hold the number of items in the linked list, then create one more linkedList and perform the bottom-up merge-sort like you would do with a simple array.</p> <p>Structures:</p> <pre><code>public class Item { private String word; private Item next; public Item(String word) { this.word = word; } public Item getNext() { return next; } public void setNext(Item next) { this.next = next; } public String getWord() { return word; } public void setWord(String word) { this.word = word; } } </code></pre> <p>Linked List:</p> <pre><code>public class LinkedList { private int size = 0; private Item first = null; public void swapFragment(LinkedList list, int from, int to) { if (from &gt;= 0 &amp;&amp; to &lt; size) { list.get(to-from).setNext(this.get(to+1)); if (from &gt; 0) { this.get(from-1).setNext(list.get(0)); } else { this.first = list.get(0); } } } public void addItem(String word) { if (first == null) { first = new Item(word); } else { Item item = first; while (item.getNext() != null) { item = item.getNext(); } item.setNext(new Item(word)); } this.size++; } public Item get(int index) { if (index &gt;= size) { return null; } else { Item item = first; for(int i = 1; i &lt;= index; i++) { item = item.getNext(); } return item; } } public int getSize() { return size; } public void setSize(int size) { this.size = size; } public String toString() { Item item = first; String message = null; if (item != null) { message = item.getWord() + " "; } else { return null; } while (item.getNext() != null) { item = item.getNext(); message = message + item.getWord() + " "; } return message; } } </code></pre> <p>Merge Sort:</p> <pre><code>public class ListMergeSort { public void sort(LinkedList list, int lo, int hi) { if (hi &lt;= lo) { return; } int mid = lo + (hi-lo)/2; sort(list, lo, mid); sort(list, mid+1, hi); merge(list, lo, hi, mid); } private void merge(LinkedList list, int lo, int hi, int mid) { int i = lo; int j = mid+1; LinkedList newList = new LinkedList(); for (int k = lo; k &lt;= hi; k++) { if (i &gt; mid) { newList.addItem(list.get(j).getWord()); j++; } else if (j &gt; hi) { newList.addItem(list.get(i).getWord()); i++; } else if (list.get(i).getWord().compareTo(list.get(j).getWord()) &lt; 0) { newList.addItem(list.get(i).getWord()); i++; } else { newList.addItem(list.get(j).getWord()); j++; } } list.swapFragment(newList, lo, hi); } } </code></pre> <p>Test Class for Strings:</p> <pre><code>import org.junit.*; public class MergeTest { @Test public void testWords() { LinkedList list = new LinkedList(); list.addItem("word"); list.addItem("pipe"); list.addItem("trainer"); list.addItem("stark"); list.addItem("33"); list.addItem("dmitry"); ListMergeSort lms = new ListMergeSort(); lms.sort(list, 0, list.getSize()-1); } } </code></pre> <p>Now you just need to create a class which receives a string as an argument, splits it with String.split() and adds the resulting words into the internal LinkedList datastructure. Then you sort them inside with the merge sort and you get the result.</p>