I have an array of objects
[
{type:"foo",elements:[...]},
{type:"bar",elements:[...]},
{type:"any",[...]},
{type:"some",elements:[...]}
]
I know how to sort that array by the attribute 'type' using underscore's _.sortBy() method.
But now I need a custom sort order which depends on another array:
["any","foo","some","bar"]
How would my sortBy callback have to look like to sort my objects by my custom order?