There are some products on a Product Listing page. I'm automating a A-Z sorting functionality. To cross verify whether website sorting option working fine, I'm adding all available product in a list and using Collection.sort()
method as its not working as expected.
This is my piece of code looks like :
public static void main(String[] args) {
List<String> x = new ArrayList<>();
x.add("Liquid Egg Whites");
x.add("LiquiFlav™");
Collections.sort(x);
System.out.println(x);
}
Output:
[LiquiFlav™, Liquid Egg Whites]
While expected should be:
[Liquid Egg Whites, LiquiFlav™]
As per alphabetical order Liquid Egg Whites
should come first.
Can anyone please explain why this happening ? and other method to get the expected result.