mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
enhancement (#803)
This commit is contained in:
parent
76061ab2cc
commit
c47c1ab03c
|
@ -29,12 +29,7 @@ def parse_file(file_path):
|
|||
if not c:
|
||||
break
|
||||
chars[c] = chars[c] + 1 if c in chars.keys() else 1
|
||||
letters = []
|
||||
for char, freq in chars.items():
|
||||
letter = Letter(char, freq)
|
||||
letters.append(letter)
|
||||
letters.sort(key=lambda l: l.freq)
|
||||
return letters
|
||||
return sorted([Letter(c, f) for c, f in chars.items()], key=lambda l: l.freq)
|
||||
|
||||
def build_tree(letters):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user