I am new to javascript programming, I have a scenario as below -
I have a input of array list of elements --> [abc,xyz,123] and output will look as follows in array object
[
{
"label" : "positive",
"id" : "abc"
},
{
"label" : "positive",
"id" : "xyz"
},
{
"label" : "negative",
"id" : "abc"
},
{
"label" : "positive and negative",
"id" : "abc"
},
{
"label" : "neg",
"id" : "123"
},
{
"label" : "positive",
"id" : "xyz"
}
]
Now I will have to sequence the output based on input sequence -
here abc is first element xyz is second element 123 is third element
so my output should something look like, all the id= "abc" should be first then "xyz" objects should display and then "123" objects
[
{
"label" : "positive",
"id" : "abc"
},
{
"label" : "negative",
"id" : "abc"
},
{
"label" : "positive and negative",
"id" : "abc"
},
{
"label" : "positive",
"id" : "xyz"
},
{
"label" : "positive",
"id" : "xyz"
},
{
"label" : "neg",
"id" : "123"
}
]
Any suggestions on how we can achieve this, please