I need to sort all the elements in all lists by the number of similarities
var list1 = ["a", "b", "c", "d"];
var list2 = ["a", "c"],
var list3 = ["c", "d"],
var list4 = ["d"],
output:
["c", "a", "d", "b"]
All four lists have c value, that is why, it is first, then a,d,b
Should sort all lists in this way.
Thanks!