I want to Sort a Linked List, I have watched so many tutorials videos and examples, and I know how to sort a Linked List, but only Linked Lists with a single String, my Linked List is composed by sentences and I have to sort using one word in the sentences for example.
this list (Number Two: 2), (Number three : 3), (Number one : 1) like this (Number one: 1), (Number Two: 2), (Number three : 3)
I tried to split my linked list and use an iterator but I don't know what to do after.please help.
private LinkedList<String> list = new LinkedList<String>();
list.add("Number three : 3");
list.add("Number One : 1");
list.add("Number two : 2");
for(Iterator<String> iterator =list.iterator(); iterator.hasNext(); )
{
String string = iterator.next();
for (String word : string.split(" ")){
/* if (int.TryParse(word)){ Maybe to get the number?
}*/
}
}
15 hours trying to figure out this, so any idea is welcome :).
Collections.sort(list);