Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode sorting #5

Open
JackPotte opened this issue Jun 1, 2017 · 0 comments
Open

Unicode sorting #5

JackPotte opened this issue Jun 1, 2017 · 0 comments

Comments

@JackPotte
Copy link

JackPotte commented Jun 1, 2017

Would it be possible to sort some non-English words please?

I can't send any pull request but this should work into LineOperations.java:

import java.text.Collator;
import java.util.Locale;
// line 149
                        Comparator<String> comparator = null;
                        Collator collator = null;
                        if (descending) {
                            if (matchCase) {
                                comparator = REVERSE_STRING_COMPARATOR;
                            } else {
                                comparator = REVERSE_STRING_COMPARATOR_CASE_INSENSITIVE;
                            }
                        } else {
                            if (matchCase) {
                                Locale locale = new Locale("fr_FR");
                                collator = Collator.getInstance(locale);
                            } else {
                                comparator = String.CASE_INSENSITIVE_ORDER;
                            }
                        }

                        if (isRemoveDuplicateLines()) {
                            SortedSet<String> uniqifySet = new TreeSet<String>(matchCase ? null : String.CASE_INSENSITIVE_ORDER);
                            uniqifySet.addAll(Arrays.asList(linesText));
                            linesText = uniqifySet.toArray(new String[0]);
                        }

                        if (comparator == null) {
                            Arrays.sort(linesText, collator);
                        } else {
                            Arrays.sort(linesText, comparator);
                        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant