This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Java in General and the fly likes Collections.sort in java using locale ???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Collections.sort in java using locale ????" Watch "Collections.sort in java using locale ????" New topic

Collections.sort in java using locale ????

Frank Jacobsen
Ranch Hand

Joined: May 17, 2002
Posts: 358
I Want to sort a list, with a danish locale, but when i try to sort like this it sort First "�" then "�" then "�" the exact wrong way, can i give a locale or how do i sort this list correct:

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Locale-specific String comparison can only be done using a Collator I think. If you get a Collator for a Danish Locale and have your SortTekstComparator test for ordering with, element2) instead you should see the results you expect.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
It is sorta covered in the JavaRanch Style Guide.
subject: Collections.sort in java using locale ????
It's not a secret anymore!