added a function to sort an array based on another array