added sorted index and index of array functions