sort values at some but not all indices of an array