Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sorting
#24
(Mar-18-2017, 10:23 AM)wavic Wrote: I still don't get it. Can you convert lambda x: (0, x) if isinstance(x, (int, float)) else (1, str(x))) to a normal function, please

def sortkey(x):
    return (0,x) if isinstance(x, (int, float)) else (1, str(x))
Or in slow-motion:

def sortkey(x):
    if isinstance(x,int) or instance(x,float): 
        return (0,x) 
    else:
        return (1, str(x))
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
sorting - by Skaperen - Mar-15-2017, 04:04 AM
RE: sorting - by wavic - Mar-15-2017, 04:40 AM
RE: sorting - by Skaperen - Mar-15-2017, 05:04 AM
RE: sorting - by wavic - Mar-15-2017, 05:35 AM
RE: sorting - by zivoni - Mar-15-2017, 07:15 AM
RE: sorting - by Skaperen - Mar-15-2017, 09:04 AM
RE: sorting - by zivoni - Mar-15-2017, 09:56 AM
RE: sorting - by wavic - Mar-15-2017, 11:10 AM
RE: sorting - by zivoni - Mar-15-2017, 11:52 AM
RE: sorting - by wavic - Mar-15-2017, 01:06 PM
RE: sorting - by Skaperen - Mar-16-2017, 02:04 AM
RE: sorting - by ichabod801 - Mar-17-2017, 12:24 AM
RE: sorting - by Skaperen - Mar-17-2017, 02:39 AM
RE: sorting - by wavic - Mar-17-2017, 07:41 AM
RE: sorting - by zivoni - Mar-17-2017, 09:29 AM
RE: sorting - by wavic - Mar-17-2017, 09:54 AM
RE: sorting - by zivoni - Mar-17-2017, 10:18 AM
RE: sorting - by Skaperen - Mar-18-2017, 02:46 AM
RE: sorting - by zivoni - Mar-18-2017, 10:16 AM
RE: sorting - by wavic - Mar-18-2017, 10:23 AM
RE: sorting - by Ofnuts - Mar-18-2017, 10:57 PM
RE: sorting - by ichabod801 - Mar-18-2017, 10:37 AM
RE: sorting - by zivoni - Mar-18-2017, 11:20 AM
RE: sorting - by wavic - Mar-18-2017, 11:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sorting a copied list is also sorting the original list ? SN_YAZER 3 3,270 Apr-11-2019, 05:10 PM
Last Post: SN_YAZER

Forum Jump:

User Panel Messages

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