added key-index counting sort