firstArray
[
{
type:"one",
ID : "1",
isValid:"true"
},
{
type:"two",
ID : "2",
isValid:"false"
},
{
type:"two",
ID : "3",
isValid:"true"
}
]
I have an array of object like the above one. i have to take all the valid objects. By iterating them,I ll get an array of objects which contains only valid objects. I have done this part successfully.
var valid_types = $.grep(firstArray, function(v)
{
return v.isValid=== "true";
});
["two","five","three","one","four"]
I have another array which specifies the sorting order. How do i sort the resulting array based on the type? I am confused a bit. Any suggestions? I have to sort valid_types based on type
Doubts: Resulting array can have same type of valid objects and it may not have all the types specified in the sorting order. How to handle this?
DESIRED ARRAY:
[
{
type:"two",
ID : "3",
isValid:"true"
},
{
type:"one",
ID : "1",
isValid:"true"
}
]