Ticket #8953: sort_relations_with_accented_letters.patch

File sort_relations_with_accented_letters.patch, 1.4 KB (added by windu.2b, 12 years ago)
  • src/org/openstreetmap/josm/tools/AlphanumComparator.java

     
    11package org.openstreetmap.josm.tools;
    22
     3import java.text.Collator;
    34/*
    45 * The Alphanum Algorithm is an improved sorting algorithm for strings
    56 * containing numbers. Instead of sorting numbers in ASCII order like a standard
     
    2324 *
    2425 */
    2526import java.util.Comparator;
     27import java.util.Locale;
    2628
    2729/**
    2830 * The Alphanum Algorithm is an improved sorting algorithm for strings
     
    7779        } else if (s2 == null) {
    7880            return 1;
    7981        }
    80 
     82       
    8183        int thisMarker = 0;
    8284        int thatMarker = 0;
    8385        int s1Length = s1.length();
     
    106108                    }
    107109                }
    108110            } else {
    109                 result = thisChunk.compareTo(thatChunk);
     111                // Instantiate the collator
     112                Collator compareOperator = Collator.getInstance(Locale.getDefault());
     113                // Compare regardless of accented letters
     114                compareOperator.setStrength(Collator.SECONDARY);
     115                result = compareOperator.compare(thisChunk, thatChunk);
    110116            }
    111117
    112118            if (result != 0) {