Implement a simple partitioning routine