The Dutch Flag Problem

The colors are represented by integers (either 0, 1 or 2).

Provided functions

This world is very simple, with only 5 provided functions.

[!java]void [/!]swap([!java]int [/!]x[!scala]:Int[/!], [!java]int [/!]y[!scala]:Int[/!])
Swap the lines number x and y.
[!java]int [/!]getSize() [!scala]:Int[/!]
Returns the amount of lines on this flag.
[!java]int [/!]getColor([!java]int [/!]line[!scala]:Int[/!])  [!scala]:Int[/!]
Returns the color of the given line.
[!java]boolean [/!]isSorted()  [!scala]:Boolean[/!]
Returns whether the flag is sorted.
[!java]boolean [/!]isSelected()  [!scala]:Boolean[/!]
Returns whether the current world is selected in the interface.