I have the following function below:
function GeraHorario(inicio,fim,tempoConsulta)
{
var agenda = []
var data = new Date(2016, 0, 1, inicio, 0, 0, 0)
var horainicial = inicio
while (data.getDate() == 1) {
if(data.getHours() < fim)
{
var horario = data.toLocaleTimeString('pt-BR');
data.setMinutes(data.getMinutes()+tempoConsulta);
var d1 = horario.replace(/(.*)\D\d+/, '$1');
agenda.push(d1);
}else{break}
}
console.log(agenda)
return agenda
}
This function generates this array
["09:00", "09:10", "09:20", "09:30", "09:40", "09:50", "10:00", "10:10", "10:20", "10:30", "10:40", "10:50", "11:00", "11:10", "11:20", "11:30", "11:40", "11:50", "12:00", "12:10", "12:20", "12:30", "12:40", "12:50", "13:00", "13:10", "13:20", "13:30", "13:40", "13:50", "14:00", "14:10", "14:20", "14:30", "14:40", "14:50", "15:00", "15:10", "15:20", "15:30", "15:40", "15:50", "16:00", "16:10", "16:20", "16:30", "16:40", "16:50", "17:00", "17:10", "17:20", "17:30", "17:40", "17:50", "18:00", "18:10", "18:20", "18:30", "18:40", "18:50"]
I make a map in the array and it looks like this. This is the function used in map
function GroupHoras(array)
{
var result = array.reduce(function( map, hourStr ) {
var hour = hourStr.charAt(0) + hourStr.charAt(1);
if (!map.hasOwnProperty(hour)) map[hour] = [];
map[hour].push(hourStr);
return map;
}, {});
return result
}
It looks like after the map
Object {10: Array[6], 11: Array[6], 12: Array[6], 13: Array[6], 14: Array[6], 15: Array[6], 16: Array[6], 17: Array[6], 18: Array[6], 09: Array[6]}
However as you can see, the value 09 should be at the beginning, go to the end of the array of objects. How do I ordernar this subject increasingly?