I am working on this code to print all the letters that follow a vowel in words of string and count the frequency using regex in python
import re
string = 'In 1996, the Council Higher Education approved the creation of the Center Consulting Research which was renamed King Abdullah Center Consulting Research. '
result = re.findall(r'[aeiou][^aeiou\s]+', string)
myArr = {}
for value in result:
if not value[1] in myArr:
myArr[value[1]] = 0
myArr[value[1]] += 1
print(myArr)
for chr, value in myArr.items():
print(chr, "->", value)
the output:
n -> 11
l -> 4
g -> 1
r -> 5
c -> 2
t -> 2
p -> 1
v -> 1
d -> 2
f -> 1
s -> 3
m -> 1
h -> 1
it's work good but I need to print it in Descending Order
according to their occurrence frequency. In fact, I don't have enough experience in python
I try sorted(myArr, key=lambda myArr: value[1])
but it doesn't work. Is there any way to sort?
Expected Output:
n -> 11
r -> 5
l -> 4
s -> 3
....