4

I've bunch of products, Which names start with word "Bai" and afterwards some digits.

Like, Bai-10, Bai-11, Bai-15 etc.

I've set Default product listing sort by to "use config setting" and at global level I've set it to "Product Name".

When I visit category page, I can see something like this.

enter image description here

Take a look at second row after Bai-10, Bai-14 should come but Bai-103 comes up.

Has anybody faced this type of issue ? Looks like its small thing but I'm not getting it.

Any help would be really appreciated.

  • please reindexing and flush caching after check and also check Log File. – Vishal Baraiya Nov 27 '19 at 9:41
3

That is lexicographic sorting which means basically the language treats the variables as strings and compares character by character "200" is greater than "19999" because '2' is greater than '1'. So in your case Bai-10, Bai-103, then Bai-14 because of Bai-10 is common and then again sorting is check so 0 (03 Bai-103) is come before (4 Bai-14).

The sorting is strictly alphabetical (and happens left-to-right, one character at a time): 1, 2, 10 makes sense to you but not to a computer that only knows alphabetic comparison. There's no way in that kind of simple comparison to know that a one followed by a 0 actually comes after a four.

| improve this answer | |
  • 1
    nice answer.!!!! keep posting answer bro..! – Sunny Rahevar Nov 27 '19 at 9:48
  • I would suggest parsing the sort field into two separate ones. The first, obviously alphabetical, the second, numerical, preferably integer based. – Francis Phillips Nov 27 '19 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.