How would I sort the first array into a final product that reflects the second array, please?
(I'm sorting first by Category but then I'm sorting by Subcategory while pushing 'Other' to the end of the Category's section.)
Input:
var unsorted = [
{category: 'Computer', subcategory: 'Laptop'},
{category: 'Computer', subcategory: 'Other'},
{category: 'Computer', subcategory: 'Desktop'},
{category: 'Network Device', subcategory: 'Gateway'},
{category: 'Computer', subcategory: 'Virtual'},
{category: 'Network Device', subcategory: 'Other'}
]
Desired Output:
var sorted = [
{category: 'Computer', subcategory: 'Desktop'},
{category: 'Computer', subcategory: 'Laptop'},
{category: 'Computer', subcategory: 'Virtual'},
{category: 'Computer', subcategory: 'Other'},
{category: 'Network Device', subcategory: 'Gateway'},
{category: 'Network Device', subcategory: 'Other'}
]
I've seen great answers for double-sorting and for pushing certain values to the end, but I haven't seen an answer for doing both at once in this way.
Thank you for your time!
Kind Regards, Joseph