Reputation: 99
I need help with sorting data in array, I want to sort Time in my table. My time format have HH:MM, in firebase its: {hour:07,minute:15}, and this is how i sort with hour:
this.array.sort((a, b) => a.data.hour- b.data.hour);
Evryting is ok till i face two same hours:
Is there chance to sort hours first than minutes? Or any other idea is acceptable.
Upvotes: 1
Views: 51
Reputation: 22574
You can first sort on hour
and then on minute
.
this.array.sort((a, b) => a.data.hour - b.data.hour || a.data.minute - b.data.minute);
Upvotes: 2