5
aramsey
7y

I have a question that my friend and I can't work out an answer for. Is a list of length 0 sorted?
A list of length 1 is sorted so you'd expect this to be sorted but then there's no items to be sorted. But does this mean it it sorted???

Comments
  • 3
    As there are no elements that could be unsorted I'd consider it sorted.

    You can only have elements in the wrong order if there are at least 2 of them.
  • 2
    I'd say it's unsorted as there's is nothing to sort. But anyway Ita like asking what colour the apples are in an empty basket. I mean... Cmon...
  • 2
    It is both sorted and unsorted.

    This was a separate course for me last year, but basically you cant show me two elements in order, so its sorted and you cant show me two elements not in order, so its unsorted.

    (Sidenote, a 2 element array is always sorted, because its either ascending or descending)
Add Comment