get the index of sorted array