Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python function for sorting list with mixed data types

import re

def mix_sorted(a_list):
    a_list = {i: (i if isinstance(i, int) else int(re.match(r'd+', i).group())) for i in a_list}
    return sorted(a_list, key= lambda x: distribution[x])
Source by app.dataquest.io #
 
PREVIOUS NEXT
Tagged: #python #function #sorting #list #mixed #data #types
ADD COMMENT
Topic
Name
1+3 =