Check to see if an array is already sorted?

前端 未结 8 1200
渐次进展
渐次进展 2020-12-17 08:52

I know how to put an array in order, but in this case I just want to see if it is in order. An array of strings would be the easiest, I imagine, and answer

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-17 09:32

    Iterate over the objects and make sure each following element is >= the current element (or previous is <=, obviously) the current element.

提交回复
热议问题