Incorrect sorting result if mixing with Chinese and English characters together.

Incorrect sorting result if mixing with Chinese and English characters together.

Normally, the ones with Chinese-char should be after the English ones.



4 Replies

JC Joseph Christ Nithin Issack Syncfusion Team March 7, 2022 03:43 PM UTC

Hi Andyzhang, 

  Greetings from Syncfusion support. 

  We are currently checking the sorting with both English and Chinese characters mixed in the same column. We will provide further details on or before 9th march 2022. We appreciate your patience until then. 

Regards, 
Joseph I. 



JC Joseph Christ Nithin Issack Syncfusion Team March 9, 2022 01:59 PM UTC

Hi Andyzhang, 

  Thanks for your patience. 

  Based on your query, when you have the Chinese and the English characters in the same column, and when you sort the column in ascending order you see the Chinese characters first instead of the English characters. We have prepared a sample to reproduce the issue from our side. But we were not able to replicate the issue. We have shared the sample and the screenshots for your convenience.  


Screenshots

  1. Initial load without sorting.

    The top three rows of the datasource contains the Chinese characters.

  2. Sorting in Ascending order.

    In this image you can see the English characters in the first row of the first page



    In the second image you can see the Chinese characters at the last rows of the last page.


Please provide the following details so that we may be able to provide a better solution ASAP. 

  • Share a simple sample or try to reproduce the issue in the provided sample.
  • Share the Syncfusion package version you are using.

Please get back to us for further details. 

Regards, 
Joseph I. 



TE techlandandyzhang March 10, 2022 06:32 AM UTC

I have worked out why this issue happened: the sorting depends on the language option of the web explorer using.

When it is in Chinese, the Chinese chars will rank in the first place; on the contrary, if in English, the sorting results as normal.

Is there any solution for this issue? e.g. ignore the UI language option of the web explorer…






PS Pavithra Subramaniyam Syncfusion Team March 11, 2022 11:00 AM UTC

Hi Andyzhang, 
 
It is not possible to change the default language preference while sorting. However, you can implement your own sorting logic by using the column sort comparer feature. Please refer to the below code example and documentation link for more information. 
 
@Component({ 
    selector: 'app-root', 
    template: `<ejs-grid [dataSource]='data' [allowSorting]='true' height='315px'> 
                <e-columns> 
                    <e-column field='CustomerID' [sortComparer]='sortComparer' headerText='Customer ID' width=150></e-column> 
                    .  .  . 
                </e-columns> 
                </ejs-grid>` 
}) 
export class AppComponent implements OnInit { 
    // The custom function, you can add your custom logic here 
    public sortComparer = (reference: string, comparer: string) => { 
        if (reference < comparer) { 
            return -1; 
        } 
        if (reference > comparer) { 
            return 1; 
        } 
        return 0; 
    } 
} 
 
 
 
Regards, 
Pavithra S 


Loader.
Up arrow icon