good algorithm

re-construct the array,traverse the array, put the value which 1<value<=a.length to the a[value-1].
if the a[value-1]'s previous value is between 1 to a.length, put this value first in a[value-1].