private int[][] Sort(int[][] jaggedArray, FuncFilter filter, OrderdBy orderdBy)
        {
            if (jaggedArray == null)
            {
                throw new ArgumentNullException(nameof(jaggedArray));
            }

            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            int length = jaggedArray.Length;

            int[] filterArray = new int[length];

            for (int i = 0; i < length; i++)
            {
                filterArray[i] = filter(jaggedArray[i]);
            }

            BubbleSort(jaggedArray, filterArray, GetOrderBy(orderdBy));

            return(jaggedArray);
        }
        protected virtual IOrderable GetOrderableBy(OrderdBy orderdBy)
        {
            switch (orderdBy)
            {
            case OrderdBy.Descending:
            {
                return(new DescendingOrderable());
            }

            default:
            {
                return(new AscendingOrderable());
            }
            }
        }
        protected virtual FuncComparer GetOrderBy(OrderdBy orderdBy)
        {
            switch (orderdBy)
            {
            case OrderdBy.Descending:
            {
                return(OrderByDescending);
            }

            default:
            {
                return(OrderByAscending);
            }
            }
        }
        /// <summary>
        /// Sorts the specified jagged array.
        /// </summary>
        /// <param name="jaggedArray">The jagged array.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="orderdBy">The orderd by.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="jaggedArray"/> is null
        /// or
        /// <paramref name="filter"/> is null
        /// </exception>
        public int[][] Sort(int[][] jaggedArray, IComparer <int[]> filter, OrderdBy orderdBy)
        {
            if (jaggedArray == null)
            {
                throw new ArgumentNullException(nameof(jaggedArray));
            }

            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            BubbleSort(jaggedArray, filter, GetOrderableBy(orderdBy));

            return(jaggedArray);
        }
 /// <summary>
 /// Sorts the rows by the sum of the elements.
 /// </summary>
 /// <param name="jaggedArray">Input jagged array.</param>
 /// <param name="orderdBy">Is used to sort the result-set in ascending or descending order.</param>
 /// <returns>sorted jagged array</returns>
 public int[][] SumSort(int[][] jaggedArray, OrderdBy orderdBy = OrderdBy.Ascending)
 {
     return(Sort(jaggedArray, GetSumElement, orderdBy));
 }