I have this code and try to sort the output print result
# -*- coding: utf-8 -*-
from os import path as os_path, listdir as os_listdir
GETPath = os_path.join('/home/usr/Desktop/fonts')
fonts = []
for fontName in os_listdir(GETPath):
fontNamePath = os_path.join(GETPath, fontName)
if fontName.endswith('.ttf') or fontName.endswith('.otf'):
fontName = fontName[:-4]
fonts.append((sorted(fontNamePath), sorted(fontName)))
But I can not get the sort lines I have got this result
nmsbd
/home/usr/Desktop/fonts/nmsbd.ttf
font_default
/home/usr/Desktop/fonts/font_default.otf
best_font1
/home/usr/Desktop/fonts/best_font1.ttf
NotoNaskhArabic
/home/usr/Desktop/fonts/NotoNaskhArabic.ttf
best_font2
/home/usr/Desktop/fonts/best_font2.ttf
arabic_k
/home/usr/Desktop/fonts/arabic_k.ttf
arabic_beirut
/home/usr/Desktop/fonts/arabic_beirut.ttf
NotoSansArabic
/home/usr/Desktop/fonts/NotoSansArabic.ttf
ae_almateen
/home/usr/Desktop/fonts/ae_almateen.ttf
How to solve this code ?!

sortedand the.sortmethod of lists? Please read ericlippert.com/2014/03/05/how-to-debug-small-programs and meta.stackoverflow.com/questions/261592, and try to think through the intended logic of the program more carefully.