private static void Sort(int[][] jaggedArray, IRowComparer comparer, IKeyCalculator keyCalc)
        {
            if (jaggedArray == null)
            {
                throw new ArgumentNullException("jaggedArray");
            }

            for (int i = 0; i < jaggedArray.Length - 1; i++)
            {
                for (int j = 0; j < jaggedArray.Length - 1 - i; j++)
                {
                    if (comparer.Compare(jaggedArray[j], jaggedArray[j + 1], keyCalc) == 1)
                    {
                        Swap(ref jaggedArray[j], ref jaggedArray[j + 1]);
                    }
                }
            }  
                 
        }
        public int Compare(int[] first, int[] second, IKeyCalculator keyCalc)
        {
            if ((first == second) || ((first.Length == 0) && (second.Length == 0)))
                return 0;
            if ((first == null) || (first.Length == 0))
                return 1;
            if ((second == null) || (second.Length == 0))
                return -1;

            int firstKey = keyCalc.GetKey(first);
            int secondKey = keyCalc.GetKey(second);

            if (firstKey > secondKey)
            {
                return -1;
            }
            else if (firstKey < secondKey)
            {
                return 1;
            }
            else return 0;
        }
 public static void SortDescending(int[][] jaggedArray, IKeyCalculator keyCalc)
 {
     Sort(jaggedArray, new DescendingComparer(), keyCalc);
 }