I have following array that can have multiple elements in it.
"coachID" : [
"choice1",
"choice2"
]
If user chooses choice2, I would like re-arrange its content as shown below.
"coachID" : [
"choice2",
"choice1"
]
Similarly, if there are more than 2 elements in the array;
"coachID" : [
"choice1",
"choice2",
"choice3"
]
and user chooses choice2 element then array should be re-arranged as follows:
"coachID" : [
"choice2",
"choice1",
"choice3"
]
In essence, chosen element should always be placed at the beginning of the array.
How can I achieve this with TypeScript please?