1

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: enter image description here

Is there chance to sort hours first than minutes? Or any other idea is acceptable.

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.