views:

181

answers:

1

Hi

I am trying to sort some Japanese shop names using the "aiueo" order

Does anyone know if there is an algorithm to do this

I have written a comparer as follows but I believe the ja-jp culture uses the Unicode sort

internal class JewellerComparer : IComparer<string>
    {
        private readonly string _culture;

        public JewellerComparer(string culture)
        {
            _culture = culture;
        }

        public int Compare(string x, string y)
        {
            // no culture specified in constructor
            if (string.IsNullOrEmpty(_culture))
                return x.CompareTo(y);

            // otherwise to a culture sensitive comparison
            return string.Compare(x, y, false, new CultureInfo(_culture));
            //new CultureInfo(0x00010411); // ja-JP Japanese - Japan Default: 0x00000411 Unicode: 0x00010411 
        }
    }

Anyone have any ideas on how to do this?

A: 

Yes, there is. All you need is a locale-aware sorting. I am no Java expert nor user, but using strcoll combined with qsort is what I would do in C.

Alternatively, one could try using libicu (there is also a java binding), and if it offers some sorting, I am not sure if it honors the locale.

cjk