Add some code to get a sorted array depending on the ordering in another array