I am working on a data structures assignment so I am not using the built-in Linkedlist in java. I need to sort the nodes alphabetically. Can I use this type of sorting that’s built in? The assignment isn’t stressing our sorting method so I’m looking for the easiest thing. The IDE complains about my list parameter which makes me think maybe this isn’t a possibility?:
Collections.sort(list, new Comparator<String>()
{
@Override
public int compare(String text1, String text2)
{
return text1.compareToIgnoreCase(text2);
}
});
No, you can only sort lists which implement java.util.List using the built in methods.