Last modified: 2012-03-01 20:59:42 UTC
Created attachment 9997 [details] Trivial patch. I want #arraysort parser function respects current locale setting. In particular, it allows case-insensitive sorting. To achieve this, the second parameter should be passed to sort function: > sort( $array, SORT_LOCALE_STRING ); Trivial patch is attached. However, it could change default behaviour. Maintaining backward compatibility will require changes in interface. For example: > {{ #arraysort: key | asc, locale }} or > {{ #arraysort: key | asc | locale }} or > {{ #arraysort: key | order=asc | flags=locale }} or something similar. Let extension maintainer decide.
Oops, sorry, wrong component was selected. Proper component "Arrays" is not present is the list...
If we want to make locale as default in Version 2.0 (with compatibility mode active not enabling it at all), I would use "nolocale" to deactivate the behavior. > {{ #arraysort: key | asc nolocale }} I have thought about implementing further flags like "case-insensitive" or "natural" for natsort() I am just wondering about SORT_LOCALE_STRING, what exactly does it do besides case-insensitive sorting (in some languages?). Right now I don't feel too comfortable making this default with knowing so little (it's not that well documented). Also, what about natsort() for example, why is there no parameter for this key, or is it even always enabled for natsort() ? There is a natcasesort() too so if the key does nothing than changing case-sensitivity, 'asc case-sensitive' might be more appropriate than 'nolocale' here. So if nobody can answer these questions, I'd do some testing by myself first before properly implementing such a flag system.
Alright, I added the functionality in r112642. for 'asce' and 'desc' sort mode the setlocale() setting will be respected. It can be deactivated by using > {{ #arraysort: key | asc nolocale }} > {{ #arraysort: key | desc nolocale }} Also, there is a new sort mode 'natural' which works with PHPs natsort(). This one doesn't respect the setlocale() though. Also, it could get nasty when it comes to UTF8 sorting and different languages, I haven't looked into that yet and probably won't in the near future.
Verified on r112642.