I am new to Python. I need to traverse the list of files in a directory, and have a 2D list of files (keys) with a value. Then I need to sort it based on their values, and delete the files with lower half of values. How can I do that?
This is what I did so far. I can't figure it out how to create such 2D array.
dir = "images"
num_files=len(os.listdir(dir))
for file in os.listdir(dir):
    print(file)
    value = my_function(file)
    #this is wrong:
    _list[0][0].append(value)
#and then sorting, and removing the files associated with lower half
Basically, the 2D array should look like [[file1, 0.876], [file2, 0.5], [file3, 1.24]], which needed to be sorted out based on second indexes.
 
     
     
    