Sorted array in Java: how can I implement? [closed]

Point 1 should be easy:

loop through the whole array
{
    if (array[THIS INDEX] > array[THIS INDEX + 1]) //the element before is greater than the next one
        ARRAY IS NOT SORTED
}

//IF LOOP IS COMPLETED AND CODE REACHES THIS POINT
ARRAY IS SORTED

Leave a Comment