Bug: Marker Listing Ordered by Title Doesn’t Handle Numbers Correctly
-
It appears that the “Order markers by” setting in the Marker Listing options for a map isn’t working correctly when ordered by “Title” for the Carousel mode, if not the others as well. It’s mishandling numbers.
For example, I have:
- Item 1
- Item 2
- Item 3
- Item 3a
- Item 4
- Item 5
- Item 6
- Item 7
- Item 8
- Item 9
- Item 10
- Item 11
- Item 12
as items in my map.
However, ordering the items in the marker list (for the Carousel, at the very least) by Title has the following be output:
- Item 1
- Item 10
- Item 11
- Item 12
- Item 2
- Item 3
- Item 3a
- Item 4
- Item 5
- Item 6
- Item 7
- Item 8
- Item 9
You can clearly see what’s wrong here.
I’m guessing the sort that’s being performed is comparing one character at a time (making the 1 in 1 and 10-12 be next to each other) rather than checking for full/proper alphanumeric sorting (obviously having it count as one would expect.)
It seems like the fix might be to use
natcasesort()
(https://www.php.net/manual/en/function.natcasesort.php) for this so natural sorting (proper alphanumeric handling instead of “standard”sort()
sorting) that’s case-insensitive (I don’t think capitalization should alter the position of an item when sorting by title) is performed.
- You must be logged in to reply to this topic.