using System.Collections.Generic;
using Net.Eagle0.Eagle.Views;

namespace eagle {
    public class HeroComparer : Comparer<HeroView> {
        public override int Compare(HeroView left, HeroView right) {
            if (left == null && right != null) return -1;
            if (left == null) return 0;
            var sortKeyCount = left.SortKeys.Count;
            if (sortKeyCount != right.SortKeys.Count)
                return sortKeyCount.CompareTo(right.SortKeys.Count);

            for (int i = 0; i < sortKeyCount; i++) {
                var lsk = left.SortKeys[i].SortKey;
                var rsk = right.SortKeys[i].SortKey;
                if (lsk != rsk) { return lsk.CompareTo(rsk); }
            }
            return 0;
        }

        public static Comparer<HeroView> Shared = new HeroComparer();
    }
}