Another method employs the Dutch National Flag Algorithm, which sorts the array in a single traversal. It utilizes three pointers: one for the next position of 0, another for the next position of 2, and a third to iterate through the array. Below is the Python code implementing this technique: def sortArray ( nums ) : low , mid , high = 0 , 0 , len ( nums ) - 1 while mid <= high : if nums [ mid ] == 0 : nums [ low ] , nums [ mid ] = nums [ mid ] , nums [ low ] low += 1 mid += 1 elif nums [ mid ] == 1 : mid += 1 else : nums [ mid ] , nums [ high ] = nums [ high ] , nums [ mid ] high -= 1 return nums In this implementation, the mid pointer advances, swapping the current element with the high pointer if it equals 2, or with the low pointer if it is 0. If the element is 1, the pointer simply moves forward. This method effectively sorts the array in a single pass.