Is there a way to order the elements in the given array based on a custom criteria related to the last 3 letters of 'prop2' in descending order? The specific order should be 'ABR', 'FDE', 'ZFR'. Another array needs to be sorted with the order 'ZFR', 'FDE', 'ARB'.
Input example:
const arr = [
{ prop1: 3, prop2: '3FDE' },
{ prop1: 4, prop2: '5ZFR' },
{ prop1: 5, prop2: '7ABR' }
]
Desired output:
const arr1 = [
{ prop1: 5, prop2: '7ABR' },
{ prop1: 3, prop2: '3FDE' },
{ prop1: 4, prop2: '5ZFR' }
]
and
const arr2 = [
{ prop1: 4, prop2: '5ZFR' },
{ prop1: 3, prop2: '3FDE' },
{ prop1: 5, prop2: '7ABR' }
]