I have a collection objects in an array,
[{A:2, B:2},{A:2, B:3},{A:1, B: 2}, {A:1, B:1}]
I would like to have a sort result of property A then property B. Therefore, as a result it should be:
[{A:1, B:1}, {A:1, B:2}, {A:2, B:2}, {A:2, B:3}]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sort by A then by B. This sort works, because if
A == AthenA - Ais0. And0 || anythingis alwaysanything. So it comparesAthen differs toBisA's are equal.Using fully cross browser sort and the benefits of lazy evaluation