Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A more intelligent .sort()?
#4
@ DeaD_EyE
Wow, I can't pretend to understand it, but it works great! Thanks very much! I had a feeling there was a better way to do this!

I've tried to understand re, but it is very cryptic. I do use re to take words out of texts and leave gaps, but that's all!

My (unsorted) file names are like this: 'CE3_1_page_29.pdf', 'CE3_1_page_41.pdf', 'CE3_1_page_28.pdf', 'CE3_1_page_14.pdf'

I didn't know if I needed the whole name or not, so I tried:

match = re.search(r"CE3_(\d+)_page_(\d+)", pdf) and match = re.search(r"CE3_(\d+)_page_(\d+).pdf", pdf)

Both worked!

Now all I have to do is try and understand it!


@snippsat Thanks, I'll fetch natsort and try to use it! Thanks!
Reply


Messages In This Thread
A more intelligent .sort()? - by Pedroski55 - Jul-07-2020, 09:38 AM
RE: A more intelligent .sort()? - by DeaD_EyE - Jul-07-2020, 11:11 AM
RE: A more intelligent .sort()? - by snippsat - Jul-07-2020, 05:47 PM
RE: A more intelligent .sort()? - by Pedroski55 - Jul-07-2020, 10:49 PM
RE: A more intelligent .sort()? - by DeaD_EyE - Jul-08-2020, 07:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Photo a.sort() == b.sort() all the time 3lnyn0 1 1,377 Apr-19-2022, 06:50 PM
Last Post: Gribouillis
  some ideas for intelligent list splitting? wardancer84 4 3,280 Nov-20-2018, 02:47 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020