I'm sure there is a way to do this, but I am having a little trouble getting it working. I basically have an Object Array
that is organized like:
-0
--key: "john"
--value:
---0: "some string"
---1: "some other string"
-1
--key: "julie"
--value:
---0: "some string"
---1: "some other string"
-2
--key: "jane"
--value:
---0: "some string"
---1: "some other string"
Note that I just put some string and some other string. These are actually different strings.
I would like to sort this object according to the first entry in the value array. I have already sorted the value array before pushing to the object.
I create the above object by doing something like this:
var userData = [];
userMessage.sort()
userData.push({
key: 'kate',
value: ['Please call Dan Smith', 'Sorry this is incorrect']
});
userData.push({
key: 'john',
value: ['Please call Dan Smith', 'You did not provide the correct info']
});
userData.push({
key: 'dave',
value: ['Sorry this is incorrect', 'You did not provide correct information']
})
I have a lot of different possbile messages and users this is just an example. What I would expect be outputted would be basically be all the users with Please call Dan Smith
in userMessage[0]
would be lumped together and those that have Sorry this is incorrect```` in
userMessage[0]``` would be lumped together. I do not care about the order of the keys.
userData = [
'kate': ['Please call Dan Smith', 'Sorry this is incorrect'],
'john': ['Please call Dan Smith', 'You did not provide the correct info'],
'dave': ['Sorry this is incorrect', 'You did not provide correct information']
]
I know how to do this for keys or even for values, but what is tricky is the fact that I have an array for the value.
Any suggestions?