I have the follow issue: I have this JSON response eg:
[{
"titulo": "Materia",
"horaInicio": {
"h": "08",
"m": "00"
},
"horaFin": {
"h": "10",
"m": "00"
}
}, {
"titulo": "Materia2",
"horaInicio": {
"h": "7",
"m": "00"
},
"horaFin": {
"h": "11",
"m": "00"
}
}, {
"titulo": "Materia3",
"horaInicio": {
"h": "11",
"m": "00"
},
"horaFin": {
"h": "13",
"m": "00"
}
}]
and i want to sort this array by "horaInicio" using JavaScript, i looked for some sort function like this one
function predicatBy(prop){
return function(a,b){
if( a[prop] > b[prop]){
return 1;
}else if( a[prop] < b[prop] ){
return -1;
}
return 0;
}
}
thats works for 'title' attribute but not for horaInicio neither horaFin.
some solution?