Fivetran connector workflows may need to align a selected list of fields with the order provided by a source field list. Given two integer arrays A and B, reorder B so its values follow the same relative order as they appear in A.
A contains distinct integers. Every value in B appears in A, and B may contain repeated values. Repeated values should appear together according to their position in A.
Implement sort_by_reference(A, B):
A, a non-empty list of distinct integers, and B, a list of integers whose values all occur in A.B, ordered by each value's index in A.A or B in place.def sort_by_reference(A, B):