Partition an array based on specified index.