I have an array of duplicate strings in no particular order or sorting.
const array = ["Train", "Car", "Car", "Train", "Bicycle", "Car", "Bicycle", "Car", "Train"]
I would like to sort the array in a specific order, specifically Train, Bicycle, Car
.
So it should be sorted.
["Train", "Train", "Train", "Bicycle", "Bicycle", "Car", "Car", "Car", "Car"]
Also, if the array does not contain one of the string, it should still stick to the same order and just skip that string.
I've tried a bunch of different ways to sort it, with no luck.