Changed the implementation to use a struct that contains array pointer and compare function pointer internally.