Is Array Sorted - CSharp System

CSharp examples for System:Array Sort

Description

Is Array Sorted

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w  w w  .j  a v  a  2 s.c om*/

public class Main{

        public static bool IsSorted(int[] data)
        {
            for (int i = 0; i < data.Length - 1; i++)
            {
                if (data[i] > data[i + 1]) return false;
            }
            return true;
        }
}

Related Tutorials