Java string sorting result conflict with sfcc out of the box sorting feature

67 views Asked by At

I am trying to find out whether the product sorting (A-Z and Z-A) is working fine in my sites. I have done this before and it worked perfectly. But now it is throwing an error saying the sorted result is not correct. Mostly this is happening for strings with special characters and string with alphabet+number.

A-Z sorting as per site's sfcc ootb sort

Esko High Five Super Strength Disposable
Esko Hi-Vis Day/Night Safety Vest
Living & Co Aluminium/Reinforced Concrete
Living & Co Aluminium Dining Chair
Storage Drawers A2 3 Tier
Storage Drawer Weave 2 Tier

Sort result from my java code in selenium

Esko Hi-Vis Day/Night Safety Vest
Esko High Five Super Strength Disposable
Living & Co Aluminium Dining Chair
Living & Co Aluminium/Reinforced Concrete
Storage Drawer Weave 2 Tier
Storage Drawers A2 3 Tier

As you can see the sort is reverse of what is there in my site. I tried many sorting methods and also tried many online sorting tools. They all gives me the 2nd result. Nothing gave me a sort list as in the site, which is ootb behaviour.

Sorting methods tried:

  1. Ordering.natural().isOrdered(productName)
if(productName.get(a).compareToIgnoreCase(productName.get(a+1))>0)  {
    Reporter.log(String.format("\nProducts '%s' and '%s' are not sorted",productName.get(a),productName.get(a+1)), true);
    isSorted=false;
}

Can someone help me to make the result as per the sfcc out of the box sorting?

0

There are 0 answers