I want to sort my dict values by the lowest number to the highest, my function is working like this, looping through a directory, checking if the path is a file, if yes, updating the dict with the file's name and with the file's size as the values.
I want to sort the dict values from the lowest number to the highest
Code:
def get_files_size(self):
user_files_size = {}
for files in os.listdir(self.folder):
if os.path.isfile(os.path.join(self.folder, files)):
user_files_size.update({files: os.path.getsize(os.path.join(self.folder, files))})
return user_files_size
Current Output:
{'test1.txt': 13, 'test2.txt': 0}
Excepted output:
{'test1.txt': 0, 'test2.txt': 13}