I'm trying to print the names of the folders in alphabetical order.
They obviously are when in the file directory but when I've separated parts of the folder names they won't print in alphabetical order.
This is the code:
import os, datetime
from tkinter import Tk
from tkinter.filedialog import askdirectory
SelectDrive = askdirectory(title='Select Folder')
SubjectDetail = os.listdir(SelectDrive)
ListLen = (len(SubjectDetail))
SplitList = [i.split() for i in SubjectDetail]
i = 0
while i < ListLen:
Name = SplitList[-i]
NameLen =len(Name)
DateOfBirth = (Name[NameLen-1])
Name.remove(DateOfBirth)
FullName = ' '.join(Name)
print(FullName," ", DateOfBirth)
i += 1
and the current output:
Arthur LEWIS 06111984
Sarah Rose WILLIAMS 23091974
Mark THOMAS 11062020
Lewis MCCARTNEY 15021994
and finally the output i'm looking for:
Arthur LEWIS 06111984
Lewis MCCARTNEY 15021994
Mark THOMAS 11062020
Sarah Rose WILLIAMS 23091974