Here is an array with nested arrays:
var array = [
['201', 'Tom', 'EES', 'California'],
['189', 'Charlie', 'EE', 'New Jersey'],
['245', 'Lisa', 'EEF', 'New Jersey'],
['743', 'Niall', 'EEC', 'Chicago'],
['653', 'Tim', 'EES', 'Miami'],
['333', 'Dev', 'EE', 'Washington'],
['333', 'Rhonda', 'EEC', 'Washington']
]
I would like the array to be sorted based on the third value in the subarrays, following the order [EE, EES, EEC, EEF]
.
The sorted array should look like this:
[
['189', 'Charlie', 'EE', 'New Jersey'],
['333', 'Dev', 'EE', 'Washington'],
['201', 'Tom', 'EES', 'California'],
['653', 'Tim', 'EES', 'Miami'],
['743', 'Niall', 'EEC', 'Chicago'],
['333', 'Rhonda', 'EEC', 'Washington'],
['245', 'Lisa', 'EEF', 'New Jersey']
]
Please note that the original array may vary in length, but the order of the elements should remain as specified.
Thank you for your help!