Array 3 balls

easy

You are given an array of balls coloured red, yellow and green.

Rearrange it so that all the red balls come first, then all the yellow ones, and all the green ones come last.

Follow-up: do it without extra memory - no counting array, no second array, no sort library.

How many passes over the array does your solution need?