This is not a duplicate because I want to select the order based on the chosen category by the user.
Trying to sort an array of objects by category array field i.e sort by user selected category from maybe a selected list.
Any help would be much appreciated.
var users = [
{ 'user': 'barne1y', 'age': 34, 'category':['a','b','c','d','e']},
{ 'user': 'fred', 'age': 40, 'category':['a','b','c','d']},
{ 'user': 'fred', 'age': 48, 'category':['a','b'] },
{ 'user': 'barney', 'age': 36, 'category':['a','b','c']}
];
example: I have a list of users that can be appear in multiple categories as shown in the json data above then in the UI I have a selected list with all the possible categories e.g.
<select><option>a</option><option>b</option><option>c</option><option>d</option></select>
When an option e.g a is selected the data is then sorted using that value found in the category.