Closed rachelwhitton closed 9 years ago
@rachelwhitton It is currently implemented using strnatcmp
. Is this not what you want? What would you propose instead?
Thanks for showing me strnatcmp
@simensen - I overlooked that. I'm using sculpin and calling this class to sort article titles, but it seems to be case sensitive.
Example: PHP Slow Log is sorted before Pantheon Architecture
Any tips on how to fix that? Thank you for your time!
Proposing strnatcasecmp
This function implements a comparison algorithm that orders alphanumeric strings in the way a human being would. The behaviour of this function is similar to strnatcmp(), except that the comparison is not case sensitive.
I need to document how to change that. I know it is possible to change sorting it just isn't super intuitive. You would put something like this in app/config/sculpin_services.yml
:
services:
sculpin_content_types.types.projects.collection.sorter:
class: Sculpin\Contrib\ProxySourceCollection\Sorter\MetaSorter
arguments:
- title
In this case, .projects.
represents the name of the content type. So if you are working with the default posts content type, it is .posts.
. You can create your own implementation of the sorter using the case-insensitive natural sort and use that.
Thanks @simensen - really appreciate the guidance!
@rachelwhitton Sure thing! Did it work? :)
Haven't gotten it working just yet - still trying to figure out how to use a custom class in sculpin_services.yml
I joined the #sculpin IRC channel to see if I can get some more guidance.
Feature Request
Implement natural order within the MetaSorter.php script.
Currently standard sorting seems to be used for this script, is there a way to modify the class on a local build to use natural order or is this something that could be considered for a future patch/release?
Thanks!