Use this to make the frecuency table:
table(x)
To sort just use sort.
sort(table(x), decreasing = TRUE)
Hope that helps
Similarly,
rle(sort(x))
will do the counting; you can then sort the results as desired.