I've been searching for this and can't quite figure out how to word (or just can't find) what I am looking for.
I have two javascript arrays of objects. One has a collection of requests full of IDs, the other contains an array that is basically a dictionary of what those IDs represent. I want to orderBy the requests array by a description_text that lives inside the dictionary array. I am trying to only house the IDs inside the request array as opposed to repeating them 1000 times in each array and am looking for the fastest way to do this.
Example:
$scope.requests = [
{ request_id 1, request_division_id: 1, morefeilds...},
{ request_id 2, request_division_id: 3, morefeilds...},
{ request_id 3, request_division_id: 1, morefeilds...},
{ request_id 4, request_division_id: 2, morefeilds...},
{ request_id 5, request_division_id: 4, morefeilds...}];
$scope.divDict = [
{request_division_id: 1, desc_text: 'Sahara Square'},
{request_division_id: 2, desc_text: 'Little Rodentia'},
{request_division_id: 3, desc_text: 'Rainforest District'},
{request_division_id: 4, desc_text: 'Tundratown'},]
So in this case I would need the orderby to return sorted in this order:
$scope.requests = [
{ request_id 4, request_division_id: 2, morefeilds...},
{ request_id 2, request_division_id: 3, morefeilds...},
{ request_id 1, request_division_id: 1, morefeilds...},
{ request_id 3, request_division_id: 1, morefeilds...},
{ request_id 5, request_division_id: 4, morefeilds...}];
As that is the alphabetical order according to each id's desc_text.