Implemented a generalized form of bucket sort