Segregate the values of the array

This Question Was Asked By Google

An array of strictly the characters 'R', 'G', and 'B', is given. Segregate the values of the array so that all the Rs come first, the Gs come second, and the Bs come last. You can only swap elements of the array. Do this in linear time and in-place.

Write a function solve that have the following parameter(s):
1.) a = an array of string

Example
Input:
['G', 'B', 'R', 'R', 'B', 'R', 'G']
Output:
The function will return,
['R', 'R', 'R', 'G', 'G', 'B', 'B']

Example
Input:
['R', 'R', 'G', 'B', 'R', 'G', 'R', 'B', 'G',]
Output:
The function will return,
['R', 'R', 'R', 'R', 'G', 'G', 'G', 'B', 'B']

Constraints
• The size of an array should be greater than 0 and less than 800.