Please solve the programming task below using a self-contained code snippet in a markdown code block.

You are given an integer array nums of size n containing each element from 0 to n - 1 (inclusive). Each of the elements from 1 to n - 1 represents an item, and the element 0 represents an empty space.
In one operation, you can move any item to the empty space. nums is considered to be sorted if the numbers of all the items are in ascending order and the empty space is either at the beginning or at the end of the array.
For example, if n = 4, nums is sorted if:

nums = [0,1,2,3] or
nums = [1,2,3,0]

...and considered to be unsorted otherwise.
Return the minimum number of operations needed to sort nums.
 
Please complete the following python code precisely:
```python
class Solution:
    def sortArray(self, nums: List[int]) -> int:
```