Sorting an array with two values

Posted by davit-datuashvili on Stack Overflow See other posts from Stack Overflow or by davit-datuashvili
Published on 2010-06-06T17:38:55Z Indexed on 2010/06/06 17:52 UTC
Read the original article Hit count: 285

Filed under:

I have array of colors:

String  s[]=new String[]{"red","black..............};

The only possible colors are red and black. I need an algorithm which partitions the array such that all red come before all black. How can I compare/exchange them to accomplish that?

© Stack Overflow or respective owner

Related posts about algorithm