Implement array partition