I have an array of objects and I need to sort them by the values of an attribute. The order to sort is given in the second array.
a = [ object1, object2, object3, object4]
object1.job = 'ER'
object2.job = 'AD'
object3.job = 'WE'
object4.job = 'ER'
b = ['ER', 'ER', 'WE', 'AD']
I need to sort my array a so that it returns [object1/object4, object3, object2]. How can I use my array b as a key for the sorting?
bis contradictory. It means thatERprecedes (and follows) itself.