Java sorting is not the same with MySQL sorting

后端 未结 1 1067
傲寒
傲寒 2021-01-20 02:10

I need to check the sorting in the table and table content is given by MySQL. I\'m using the following row to sort the list:
Collections.sort(sorted, String.CASE_I

1条回答
  •  醉梦人生
    2021-01-20 02:43

    Use [Collator][1]:

    The Collator class performs locale-sensitive String comparison. You use this class to build searching and sorting routines for natural language text.

    And code will be:

        Collator coll = Collator.getInstance(Locale.US);
        coll.setStrength(Collator.IDENTICAL); 
        Collections.sort(words, coll);
    

    0 讨论(0)
提交回复
热议问题