I have an ArrayList that is populated with strings from a text file, and now I want to sort it alphabetically (I can't use collections.sort or anything like that, it has to be manual).
What is the correct way to compare two elements of an ArrayList (if there is one at all)?
Collections.sortfor your needs? And FWIW,Strings areComparable, socompareToshould do for basic lexicographic comparison.compareTo? Have you read the javadoc of thecompareToto understand how it works?