I have an array of objects :
[{cat:A,size:2},
{cat:B,size:2},
{cat:B,size:1},
{cat:A,size:3},
{cat:C,size:5},
{cat:B,size:3}]
I'd like to sort this array first, by category, then by asc size in each category. The resulting array would be :
[{cat:A,size:2},
{cat:A,size:3},
{cat:B,size:1},
{cat:B,size:2},
{cat:B,size:3},
{cat:C,size:5}]
I am currently dividing the array in temporary subsets by cat, then sorting each of them by size and joining... But I have 100000+ values to sort and I am sure there's a better/faster way. I have underscore.js included in my project if that helps. The number of cat is dynamic ... Any suggestions?