I want to remove all the duplicate items in the array and arrange them in order of their occurrence from most to least
["57358e5dbd2f8b960aecfa8c",
"573163a52abda310151e5791",
"573163a52abda310151e5791",
"573163a52abda310151e5791",
"573163a52abda310151e5791",
"573163da2abda310151e5792",
"57358e5dbd2f8b960aecfa8c",
"57358e5dbd2f8b960aecfa8c"
"573163da2abda310151e5792",]
I want like this
["573163a52abda310151e5791",
"57358e5dbd2f8b960aecfa8c",
"573163da2abda310151e5792"]
as the 1st one appears the most no of times , then the second one then the 3rd one which apears only once