Ignore characters during .sort python

I need help sorting 2 lists ... with filenames and directory lists. These lists are generated through another part in a much larger script that I cannot use here.

filelist = ['EN088_EFH_030_comp_v011.mov', 'EN086_EHA_010_comp_v031.mov', 'EN083_WDA_400_comp_v021.mov', 'EN086_EHA_020_comp_v010.mov', 'EN083_WDA_450_comp_v012.mov']

folderlist = ['[EN086_EHA_010_comp_v031]', '[EN083_WDA_400_comp_v021]', '[EN086_EHA_020_comp_v010]', '[EN083_WDA_450_comp_v012]']

      

using.sort I can get the data to output as follows.

[CB083_WDA_400_comp_v021]
[CB083_WDA_450_comp_v012]
[CB086_EHA_010_comp_v031]
[CB086_EHA_020_comp_v010]
CB083_WDA_400_comp_v021.mov
CB083_WDA_450_comp_v012.mov
CB086_EHA_010_comp_v031.mov
CB086_EHA_020_comp_v010.mov
CB088_EFH_030_comp_v011.mov

      

But I need it to output like this

[CB083_WDA_400_comp_v021]
CB083_WDA_400_comp_v021.mov
[CB083_WDA_450_comp_v012]
CB083_WDA_450_comp_v012.mov
[CB086_EHA_010_comp_v031]
CB086_EHA_010_comp_v031.mov
[CB086_EHA_020_comp_v010]
CB086_EHA_020_comp_v010.mov
CB088_EFH_030_comp_v011.mov

      

How can I sort it, but ignoring [] while sorting?
Or what would I do to get a second exit?
I kind of underestimate what I have to do.
Any tips or suggestions?

+3


source to share


1 answer


....sort(key=lambda x: x.strip('[]'))

      



+11


source







All Articles