smartinsightsfromdata/rpivotTable

Sort rows in locale with characters not found in English

Opened this issue · 0 comments

Mkranj commented

Hi, I have a variable that I'd like to sort my data by rows in rpivotTable. The issue is, since the data is in Croatian which uses some letters not found in English, the output is not alphabetically sorted, e.g. it sorts first by English characters, and then by Croatian.

Example:

engleski, francuski, hrvatski, talijanski, češki, španjolski

Expected order:

češki, engleski, francuski, hrvatski, španjolski, talijanski

Can I somehow define the character order in a locale?
Here is a somewhat related solution I wrote for correctly sorting the months of a year:

sortiranje_mjeseci_js = "
        function(attr) {
        var sortAs = $.pivotUtilities.sortAs;
        if (attr == \"Mjesec\") { return sortAs([\"siječanj\", \"veljača\", \"ožujak\", \"travanj\", \"svibanj\", \"lipanj\", \"srpanj\", \"kolovoz\", \"rujan\", \"listopad\", \"studeni\", \"prosinac\", \"nepoznato\"]); }
        }"

and then I passed that to the sorters argument of pivotTable. However, I can't do the same for the variable I describe first because not all values are known in advance. I'd be grateful for any tips!