/// <summary>
        /// Sort by max amount of bubble elements.
        /// </summary>
        /// <param name="matrixInts">Integer matrix elements</param>
        /// <param name="sort">Interface realization</param>
        /// <param name="flag">Sorting direction</param>

        public static void BubbleSortMaxElements(ref int[][] matrixInts, ISort sort, bool flag)
        {
            if (ReferenceEquals(matrixInts, null) || ReferenceEquals(sort, null))
            {
                throw new ArgumentNullException();
            }

            var sizeRow = matrixInts.GetLength(0);

            int[] maxInts = MaxVal(matrixInts, sizeRow);

            for (var i = 0; i < sizeRow; i++)
            {
                for (var j = i; j < matrixInts.Length; j++)
                {
                    if (flag)
                    {
                        if (sort.SortMax(maxInts[i], maxInts[j]))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!(sort.SortMax(maxInts[i], maxInts[j])))
                        {
                            continue;
                        }
                    }

                    ChangeArrayIndex(ref matrixInts, i, j);
                    Swap(ref maxInts[i], ref maxInts[j]);
                }
            }
        }