I have here 2 array's
1st array is the main data and 2nd array by property it must be the bases of 1st array data orders.
2nd array sample :
var order_basis = [
{ tag:'vip' }, { tag:'home' } { tag:'work' }
]
1st array data
var main_data = [
{ tag:'work',name:'sample',contact:'0987654',email:'sample@email.com' },
{ tag:'home',name:'sample',contact:'0987654',email:'sample@email.com' },
{ tag:'home',name:'sample',contact:'0987654',email:'sample@email.com' },
{ tag:'work',name:'sample',contact:'0987654',email:'sample@email.com' },
{ tag:'vip',name:'sample',contact:'0987654',email:'sample@email.com' },
]
expected output is
base on the 2nd array tag order it must be ..
ReOrder( main_data ,order_basis ){
//main code
return
}
result is
tag:'vip' name:'sample' contact:'0987654' email:'sample@email.com'
tag:'home' name:'sample' contact:'0987654' email:'sample@email.com'
tag:'home' name:'sample' contact:'0987654' email:'sample@email.com'
tag:'work' name:'sample' contact:'0987654' email:'sample@email.com'
tag:'work' name:'sample' contact:'0987654' email:'sample@email.com'
Thank you for helping mate! ..