The first problem is the structure of your data. You have effectively an array like
var data = [ "foo", "bar" ];
and these lines of strings contain serialized data. So first we need to extract the data via any method given in this SO question, for example the JSON library method:
var interpreted = [];
for(var i=0; i<data.length; ++i) {
interpreted[i] = JSON.parse(data[i]);
}
Now we have structures like this:
[
0: {
'Firstname': 'xyz',
'Lastname' : 'QSD', // there is a colon missing in the
// source, I'm guessing accidentally
...
},
1: {
'Firstname' : 'abc',
...
}
]
So we can access the firstname via interpreted[i].Firstname
. Now we can sort in a similar way to this other SO question, by passing sort()
a comparison function:
interpreted.sort(function(a,b) {
if(a.Firstname == b.Firstname)
return 0;
if(a.Firstname > b.Firstname)
return 1;
else
return -1
} );
Where you need to swap 1 and -1 if you want to sort descending.